{"id":21739,"library":"pycld3","title":"pycld3","description":"Python CFFI bindings for Google's Compact Language Detector v3 (CLD3). Provides language detection with a compact neural network. Current version is 0.22. Releases are infrequent; no active development since 2020.","status":"active","version":"0.22","language":"python","source_language":"en","source_url":"https://github.com/bsolomon1124/pycld3","tags":["language-detection","cld3","nlp","cffi"],"install":[{"cmd":"pip install pycld3","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The package name on PyPI is pycld3, but the module is imported as pycld3. A common mistake is to import cld3 (which matches the Google library name).","wrong":"import cld3","symbol":"pycld3","correct":"import pycld3"}],"quickstart":{"code":"import pycld3\n\n# Detect language of a text\nresult = pycld3.classify('This is a test')\nprint(result)  # LanguageResult(language='en', probability=0.9999, reliable=True)\n\n# Get top N languages\nresults = pycld3.top_n('This is a test', 3)\nprint(results)  # [LanguageResult(language='en', ...), ...]\n\n# Language identification for multiple texts\nfor text in ['Bonjour', 'Hola', 'Hello']:\n    result = pycld3.classify(text)\n    print(f\"{text} -> {result.language}\")","lang":"python","description":"Basic usage of pycld3 to detect language of a string and get top N languages."},"warnings":[{"fix":"Use Python 3.6 or newer.","message":"Python 3.6+ only: pycld3 0.22 drops support for Python 3.5 and earlier. Import error on older versions.","severity":"breaking","affected_versions":">=0.22"},{"fix":"if not result.reliable: handle uncertain detection.","message":"Check for reliable flag: The language detection may return a low probability result. Always check the `reliable` boolean attribute before trusting the output.","severity":"gotcha","affected_versions":"all"},{"fix":"Use locks or single-threaded access.","message":"Thread safety: The underlying C library is not thread-safe. Do not call classify or top_n concurrently from multiple threads without locking.","severity":"gotcha","affected_versions":"all"},{"fix":"Change import from cld3 to pycld3.","message":"The `cld3` import alias (import cld3) was removed in version 0.22. Use `import pycld3`.","severity":"deprecated","affected_versions":">=0.22"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use 'import pycld3' instead of 'import cld3'.","cause":"Trying to import pycld3 as 'cld3' (the old name).","error":"ModuleNotFoundError: No module named 'cld3'"},{"fix":"Reinstall pycld3: pip install --force-reinstall pycld3","cause":"Missing native library; pycld3 ships its own shared library but it may not be installed correctly.","error":"OSError: libcld3.so: cannot open shared object file: No such file or directory"},{"fix":"Use 'pycld3.classify' and 'pycld3.top_n' instead.","cause":"API mismatch: older code used 'pycld3.CLD3'.","error":"AttributeError: module 'pycld3' has no attribute 'CLD3'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}