Registry / serialization / pyenchant

pyenchant

JSON →
library3.3.0pypypi✓ verified 28d ago

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.

pip install pyenchant
INSTALL
IMPORT
SIG · PYENCHANT
P
pyenchant
serializationpythonv3.3.0
Install
1.6s avg
Import
—
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v3.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.1MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

enchant
✓ import enchant
The PyPI package is 'pyenchant', but the module imported is 'enchant'.

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.

import enchant try: # Initialize a dictionary for American English # Replace 'en_US' with your desired language tag # Ensure the corresponding Enchant dictionaries are installed on your system d = enchant.Dict("en_US") # Check if a word is spelled correctly word_correct = "hello" print(f"'{word_correct}' is spelled correctly: {d.check(word_correct)}") word_incorrect = "helllo" print(f"'{word_incorrect}' is spelled correctly: {d.check(word_incorrect)}") # Get suggestions for a misspelled word suggestions = d.suggest(word_incorrect) print(f"Suggestions for '{word_incorrect}': {suggestions}") except enchant.errors.DictNotFoundError: print("Error: Dictionary for the specified language was not found.") print("Please ensure the Enchant C library and relevant language dictionaries are installed.") except enchant.errors.EnchantError as e: print(f"An Enchant error occurred: {e}") print("Ensure the Enchant C library is properly installed and accessible.")
Debug
Known issues
breakingVersion 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.
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.
affects: >=3.0.0
breakingThe return type of `enchant.get_enchant_version()` changed from `bytes` to `str` in version 3.1.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.
affects: >=3.1.0
gotchaPyEnchant 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.
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.
affects: All versions
gotchaAfter 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`.
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.
affects: All versions
gotchaOn 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.
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.
affects: >=3.1.1
Errors
Common errors & fixes
ImportError: The 'enchant' C library was not found. Please install it via your OS package manager, or use a pre-built binary wheel from PyPI.
PyEnchant is a Python binding for the Enchant C library; this error means the underlying C library is not installed or cannot be located by PyEnchant on your system.
fix
Install the Enchant C library using your operating system's package manager (e.g., `brew install enchant` on macOS, `sudo apt-get install enchant` or `sudo dnf install enchant` on Linux, or ensure a compatible pre-built binary wheel was installed on Windows). After installing the C library, you might need to reinstall `pyenchant` or ensure its environment variables are set correctly if the C library is in a non-standard location.
enchant.errors.DictNotFoundError: Dictionary for language 'en_US' could not be found.
This error occurs when the Enchant C library is installed, but the specific dictionary files for the requested language (e.g., 'en_US') are missing or not discoverable in the expected locations.
fix
Install the necessary dictionary files for your spellchecker backend (e.g., `hunspell-en`, `aspell-en`). On Linux, this is typically done via your package manager (e.g., `sudo apt-get install hunspell-en-us`). On macOS, if using Homebrew with `enchant`, it usually installs default dictionaries. On Windows, you might need to manually download `.dic` and `.aff` files and place them in the correct `hunspell` directory within the Enchant data path.
ModuleNotFoundError: No module named 'enchant'
This typically means the `pyenchant` Python package itself has not been installed, or it was installed in a different Python environment than the one currently being used.
fix
Ensure `pyEnchant` is installed in your active Python environment by running `pip install pyenchant`. If you are using a virtual environment (e.g., Anaconda, venv), make sure it's activated before installation and execution.
AttributeError: module 'enchant' has no attribute 'DictWithPWL'
This error often occurs when an outdated version of `pyenchant` is installed, or when a user mistakenly installs a different package named `enchant` (which might not be the `pyenchant` wrapper for the C library) that lacks the expected attributes.
fix
First, uninstall any potentially conflicting packages (`pip uninstall enchant`). Then, ensure you have the official `pyenchant` library installed and that it's up-to-date (`pip install --upgrade pyenchant`). Refer to the `pyenchant` documentation for the correct API usage if the attribute name has changed in newer versions.
AttributeError: module 'tokenize' has no attribute 'open'
On Windows systems, an older or corrupted installation of `pyenchant` might create a `tokenize` directory within its installation path (`site-packages/enchant/tokenize`), which can conflict with Python's built-in `tokenize` module.
fix
Locate the `enchant` installation directory within your Python `site-packages` (e.g., `C:\Python\Python3x\Lib\site-packages\enchant`). If a `tokenize` folder exists directly under `enchant`, rename or remove it. Reinstalling `pyenchant` to ensure a clean, updated version is also advisable.
Upgrade
Version history
3.3.0latest on PyPI · released Sep 14, 2025
Audit
Dependencies
Enchant C libraryrequiredPyEnchant 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).
language-specific dictionariesrequiredTo 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.
Agent activity
13 hits · last 30 days
node
10
Resources
pyenchant — pip install pyenchant · libregistry