python-levenshtein is a Python C extension module providing highly optimized functions for computing string edit distances (like Levenshtein distance), similarity ratios, and related metrics. While the package itself has been renamed to `levenshtein` and is actively maintained under that name by the RapidFuzz team, the `python-levenshtein` PyPI package (version 0.27.3) continues to be updated as a compatibility wrapper. It maintains a positive release cadence.
pip install python-levenshteinVerified import paths — ran on the pinned version, not inferred.
Calculate the Levenshtein distance (minimum number of single-character edits) and a similarity ratio between two strings.
Prefer `pip install levenshtein` for new projects. If using `python-levenshtein`, be aware it acts as a shim.
Review your project's licensing compatibility. For less restrictive alternatives, consider `rapidfuzz` (MIT license) or `pylev` (New BSD license).
Ensure your project uses Python 3.10 or newer to maintain compatibility with the latest versions of the library.
For new projects or performance-critical applications, evaluate `rapidfuzz` (`pip install rapidfuzz`) as a potential alternative. It offers a similar API for many functions.
import levenshtein
Install Microsoft C++ Build Tools, typically via the 'Desktop development with C++' workload in the Visual Studio Installer.
import levenshtein
# Then use functions like: levenshtein.distance('string1', 'string2')import levenshtein