Registry / serialization / pyspellchecker

pyspellchecker

JSON →
library0.9.0pypypi✓ verified 24d ago

pyspellchecker is a pure Python spell checker based on Peter Norvig's blog post, utilizing a Levenshtein Distance algorithm to find permutations and compare them to a word frequency list. It supports multiple languages including English, Spanish, German, French, Portuguese, Arabic, and Basque. The current version is 0.9.0, and it is actively maintained with updates to support newer Python versions.

pip install pyspellchecker
INSTALL
IMPORT
SIG · PYSPELLCHECKER
P
pyspellchecker
serializationpythonv0.9.0
Install
1.6s avg
Import
37ms
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.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.103.95 runs
installs and imports cleanly · install 0.0s · import 0.040s · 24.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.034s · 25MB
23MB installed
● package 23MB
Code
Verified usage

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

SpellChecker
from spellchecker import SpellChecker
from pyspellchecker import SpellChecker
While the PyPI package is 'pyspellchecker', the primary class is imported directly from the 'spellchecker' module.

Initialize SpellChecker, identify unknown words, and get corrections or candidate spellings.

from spellchecker import SpellChecker spell = SpellChecker() mispelled_words = spell.unknown(['something', 'is', 'hapenning', 'here']) for word in mispelled_words: print(f"Correction for '{word}': {spell.correction(word)}") print(f"Candidates for '{word}': {spell.candidates(word)}")
Debug
Known issues
breakingVersion 0.9.0 removed support for Python 3.8 and 3.9. Users on these Python versions should use an older pyspellchecker version (e.g., <=0.8.x).
fix
Upgrade Python to >=3.10 or pin `pyspellchecker` to a compatible version (e.g., `pyspellchecker<0.9.0`).
affects: >=0.9.0
breakingAs of version 0.9.0, a `ValueError` is raised if `language` is used simultaneously with `case_sensitive=True` or `local_dictionary` in the `SpellChecker` constructor, as these options are mutually exclusive.
fix
Ensure that `language` is not set when `case_sensitive=True` or `local_dictionary` is provided.
affects: >=0.9.0
gotchaFor longer words or performance-critical applications, it is highly recommended to set the `distance` parameter to 1 (default is 2) during `SpellChecker` initialization or afterwards. A higher distance increases computation time significantly.
fix
Initialize `SpellChecker(distance=1)` or set `spell.distance = 1` after instantiation.
affects: All versions
gotchaSince version 0.7.0, `spell.correction()` and `spell.candidates()` will return `None` if no valid corrections or candidates are found for a given word. Previously, they might have returned the original word or an empty set.
fix
Update code to explicitly check for `None` return values from `correction()` and `candidates()` to avoid unexpected `TypeError` or `AttributeError`.
affects: >=0.7.0
gotchapyspellchecker works by comparing permutations to a word frequency list and does not inherently understand word context. This means it may suggest corrections that are grammatically or contextually incorrect in a sentence (e.g., correcting 'their' to 'there').
fix
Consider integrating with a contextual spell checker or grammar checker for applications requiring semantic understanding, or build a highly specific custom dictionary for your domain.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'spellchecker'
The `pyspellchecker` library, which provides the `spellchecker` module for importing `SpellChecker`, has not been installed.
fix
pip install pyspellchecker
AttributeError: 'list' object has no attribute 'lower'
The `correction()` method expects a single string as input, but a list of strings was provided instead.
fix
corrected_words = [spell.correction(word) for word in list_of_words]
KeyError: 'xx' (where 'xx' is an unsupported language code)
The `SpellChecker` constructor was initialized with a language code ('xx') that is not supported by the library.
fix
spell = SpellChecker(language='en') # Replace 'en' with a supported language like 'es', 'de', 'fr', 'pt', 'ar', 'eu'
ModuleNotFoundError: No module named 'pyspellchecker'
The user is trying to import `pyspellchecker` as a top-level module, but the main `SpellChecker` class is exposed through the `spellchecker` module. This can also happen if a different `spellchecker` package was installed.
fix
from spellchecker import SpellChecker
Upgrade
Version history
0.9.0latest on PyPI · released Mar 7, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.10 or higher.
Agent activity
5 hits · last 30 days
node
4
Resources
pyspellchecker — pip install pyspellchecker · libregistry