{"id":2216,"library":"pyenchant","title":"PyEnchant","description":"PyEnchant is a Python library providing bindings for the Enchant spellchecking system. It allows developers to check the spelling of words, suggest corrections, and manage dictionaries for various languages. The current version is 3.3.0, and the library maintains an active release cadence, with updates addressing Python version compatibility and bug fixes.","status":"active","version":"3.3.0","language":"en","source_language":"en","source_url":"https://github.com/pyenchant/pyenchant","tags":["spellchecker","nlp","text-processing","enchant"],"install":[{"cmd":"pip install pyenchant","lang":"bash","label":"Install PyEnchant"}],"dependencies":[{"reason":"PyEnchant is a binding to the native Enchant C library, which must be installed separately on most operating systems (e.g., via apt, brew, or MinGW).","package":"Enchant C library","optional":false},{"reason":"To perform spell-checking for a specific language (e.g., 'en_US', 'de_DE'), the corresponding dictionaries (e.g., hunspell-en_US) must be installed for the Enchant C library.","package":"language-specific dictionaries","optional":false}],"imports":[{"note":"The PyPI package is 'pyenchant', but the module imported is 'enchant'.","symbol":"enchant","correct":"import enchant"}],"quickstart":{"code":"import enchant\n\ntry:\n    # Initialize a dictionary for American English\n    # Replace 'en_US' with your desired language tag\n    # Ensure the corresponding Enchant dictionaries are installed on your system\n    d = enchant.Dict(\"en_US\")\n\n    # Check if a word is spelled correctly\n    word_correct = \"hello\"\n    print(f\"'{word_correct}' is spelled correctly: {d.check(word_correct)}\")\n\n    word_incorrect = \"helllo\"\n    print(f\"'{word_incorrect}' is spelled correctly: {d.check(word_incorrect)}\")\n\n    # Get suggestions for a misspelled word\n    suggestions = d.suggest(word_incorrect)\n    print(f\"Suggestions for '{word_incorrect}': {suggestions}\")\n\nexcept enchant.errors.DictNotFoundError:\n    print(\"Error: Dictionary for the specified language was not found.\")\n    print(\"Please ensure the Enchant C library and relevant language dictionaries are installed.\")\nexcept enchant.errors.EnchantError as e:\n    print(f\"An Enchant error occurred: {e}\")\n    print(\"Ensure the Enchant C library is properly installed and accessible.\")","lang":"python","description":"This example demonstrates how to initialize a dictionary for a specific language (e.g., American English), check the spelling of words, and retrieve spelling suggestions for misspelled words. It includes error handling for missing dictionaries or the Enchant C library."},"warnings":[{"fix":"Upgrade Python to 3.7+ (preferably 3.9+). For macOS, manually install the Enchant C library (e.g., `brew install enchant`). Review `pyenchant` documentation for detailed migration steps from older versions.","message":"Version 3.0.0 introduced significant breaking changes, including dropping support for Python 2. On macOS, the Enchant C library is no longer embedded in the wheel and must be installed separately via Homebrew or MacPorts. It also uncoupled PyEnchant's version from the Enchant C library's version and fixed compatibility issues with Enchant C library versions 2.0 and above.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Ensure your code expects a `str` return type for `get_enchant_version()`. If you were previously decoding bytes, that step is no longer necessary.","message":"The return type of `enchant.get_enchant_version()` changed from `bytes` to `str` in version 3.1.0.","severity":"breaking","affected_versions":">=3.1.0"},{"fix":"Install the Enchant C library via your operating system's package manager (e.g., `sudo apt-get install libenchant-2-dev` on Debian/Ubuntu, `brew install enchant` on macOS). For Windows, consider using MinGW/Chocolatey to install the library or ensure you're using a compatible wheel.","message":"PyEnchant requires the underlying Enchant C library to be installed on your system. It is NOT installed automatically by `pip install pyenchant` on Linux or macOS. On Windows, pre-built binary wheels might include a basic Enchant C library, but for full functionality or specific configurations (e.g., `--no-binary`), manual installation is required.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install the necessary dictionary packages using your OS package manager (e.g., `sudo apt-get install hunspell-en-us` on Debian/Ubuntu). Consult the PyEnchant documentation for details on locating or installing dictionaries on your platform.","message":"After installing PyEnchant and the Enchant C library, you also need to install language-specific dictionaries (e.g., for `en_US`, `de_DE`) which are typically provided as separate system packages (e.g., `hunspell-en-us`). Without these, PyEnchant will raise a `DictNotFoundError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If experiencing DLL issues on Windows, ensure your environment's `PATH` is correctly configured to include the Enchant C library's location, or consider the implications of how PyEnchant interacts with DLL search paths in your specific deployment.","message":"On Windows, PyEnchant version 3.1.1 changed its behavior from using `SetDllDirectory` to manipulating the `PATH` environment variable when loading the Enchant C library. This was to improve coexistence with other libraries. If you encounter DLL loading issues, especially in complex environments, this change might be relevant.","severity":"gotcha","affected_versions":">=3.1.1"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}