PyEnchant is compatible with Python versions 3.6 and above at the time of writing - tox.ini being the authoritative source.
The PyEnchant package is available on pypi.
You can install it with
pip as usual.
However, to work properly, PyEnchant needs to:
find the Enchant C library
find the dictionaries for your particular language
The way to achieve this depends on the platform you are using:
Installing the Enchant C library
The quickest way is to install libenchant using pkg(8):
pkg install enchant2
The quickest way is to install libenchant using the package manager of your current distribution. PyEnchant tries to be compatible with a large number of libenchant versions. If you find an incompatibility with your libenchant installation, feel free to open a bug report.
To detect the libenchant binaries, PyEnchant uses ctypes.util.find_library(), which requires ldconfig, gcc, objdump or ld to be installed. This is the case on most major distributions, however statically linked distributions (like Alpine Linux) might not bring along binutils by default.
The quickest way is to install libenchant using Homebrew:
brew update brew install enchant
If you are using Apple Silicon and it displays this error:
The 'enchant' C library was not found and maybe needs to be installed.,
as a workaround, you may need to install an x86_64 (Intel) version of enchant.
In order to do so, you need to install the x86_64 version of Homebrew in
/usr/local/ and then use this version to install the corresponding
version of enchant.
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" arch -x86_64 /usr/local/bin/brew install enchant
If you are using MacPorts you can also install the enchant2 package. Please make sure to add the port variants for the spellers you’d like to use. For example, to build the enchant library for aspell and hunspell, use:
sudo port install enchant2 +aspell +hunspell +applespell
The enchant C library depends on glib2, which poses some interesting challenges.
There are two ways to use install the PyEnchant library on Windows, both with their pros and cons.
Using the binary wheel
The Windows binary wheels on pypi.org contain a pre-compiled enchant library, if your Python version is compatible, it will get used by pip automatically.
“Just works” in the majority of cases
The only provider is
The only installed dictionary is for the English language
A copy of the glib2.dll and other dependencies are included
An other way to use pyenchant is to install MinGW (for instance with Chocolatey), then use pacman to install the libenchant and all its dependencies.
In that case, you can ask pip to not use the wheel by running it like this:
pip install --no-binary pyenchant
You are using the “official” way to build enchant one Windows, thanks to the work of the MinGW maintainers
You can use all the supported providers
You can add a new language using pacman
It only works with the
python3binary of the
MinGWdistribution, so typically not the one you’ve installed from python.org.
Installing a dictionary
Let’s assume you want to use PyEnchant on a text written in German.
First, use the Enchant Python API to list known languages and providers:
import enchant broker = enchant.Broker() broker.describe() broker.list_languages()
de_DE, you’re done and can move on to the
If not, you should install the dictionary for one of the listed providers.
So for instance, if the
hunspell is listed as a Enchant provider, you
should install the German dictionary for the
On FreeBSD, Linux, and macOS,this can be done
by installing the
hunspell-de or the
On Windows, if you have installed PyEnchant from a
wheel, you can download the hunspell dictionary files you need
(both the .dic and .aff extensions) and put them inside
can find many dictionaries in LibreOffice sources.
Despite our best efforts, it is possible that the procedures documented above do not work.
To have a clue about what is wrong, you can set the PYENCHANT_VERBOSE_FIND environment
variable to any non-empty value and run
python -c 'import enchant'.
If you can’t figure out what is wrong, it’s probably a bug in PyEnchant, so feel free to open an issue on GitHub, preferably containing the output of the above command.