{"library":"python-levenshtein","title":"python-levenshtein","description":"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.","status":"active","version":"0.27.3","language":"en","source_language":"en","source_url":"https://github.com/rapidfuzz/python-Levenshtein.git","tags":["levenshtein","edit distance","string similarity","fuzzy matching","nlp","c-extension"],"install":[{"cmd":"pip install python-levenshtein","lang":"bash","label":"Install `python-levenshtein` compatibility package"}],"dependencies":[{"reason":"Runtime environment","package":"python","optional":false},{"reason":"The underlying, actively developed package that `python-levenshtein` now wraps for compatibility.","package":"levenshtein","optional":false}],"imports":[{"note":"The installed module is always named `Levenshtein` regardless of the PyPI package name (`python-levenshtein` or `levenshtein`).","wrong":"from python_levenshtein import distance","symbol":"Levenshtein","correct":"import Levenshtein"}],"quickstart":{"code":"import Levenshtein\n\nstr1 = \"kitten\"\nstr2 = \"sitting\"\n\n# Calculate Levenshtein distance\ndistance = Levenshtein.distance(str1, str2)\nprint(f\"Levenshtein distance between '{str1}' and '{str2}': {distance}\")\n\n# Calculate similarity ratio\nratio = Levenshtein.ratio(str1, str2)\nprint(f\"Similarity ratio between '{str1}' and '{str2}': {ratio:.2f}\")\n\n# Example with different strings\nstr3 = \"hello\"\nstr4 = \"hallo\"\ndistance2 = Levenshtein.distance(str3, str4)\nratio2 = Levenshtein.ratio(str3, str4)\nprint(f\"\\nLevenshtein distance between '{str3}' and '{str4}': {distance2}\")\nprint(f\"Similarity ratio between '{str3}' and '{str4}': {ratio2:.2f}\")","lang":"python","description":"Calculate the Levenshtein distance (minimum number of single-character edits) and a similarity ratio between two strings."},"warnings":[{"fix":"Prefer `pip install levenshtein` for new projects. If using `python-levenshtein`, be aware it acts as a shim.","message":"The primary development for this library now occurs under the `levenshtein` PyPI package. `python-levenshtein` is maintained as a compatibility wrapper. It's recommended to install `levenshtein` directly for new projects and for accessing the latest features and fixes, though `pip install python-levenshtein` will still work by installing `levenshtein` as a dependency.","severity":"breaking","affected_versions":"All versions post-renaming (roughly 0.20.0 onwards for `levenshtein` and 0.25.0 onwards for `python-levenshtein`)."},{"fix":"Review your project's licensing compatibility. For less restrictive alternatives, consider `rapidfuzz` (MIT license) or `pylev` (New BSD license).","message":"The library is licensed under GPL-2.0. This copyleft license can be restrictive for projects with different licensing requirements, as it may necessitate that derivative works also be licensed under GPL.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your project uses Python 3.10 or newer to maintain compatibility with the latest versions of the library.","message":"Recent versions of the underlying `levenshtein` library (which `python-levenshtein` now wraps) have dropped support for older Python versions. For example, version 0.26.0 dropped support for Python 3.8, and 0.27.0 requires Python 3.10 or later.","severity":"breaking","affected_versions":"0.26.0+"},{"fix":"For new projects or performance-critical applications, evaluate `rapidfuzz` (`pip install rapidfuzz`) as a potential alternative. It offers a similar API for many functions.","message":"While `python-levenshtein` (and `levenshtein`) is highly optimized due to its C extension, for extensive fuzzy matching, especially with large datasets or when a wider array of string similarity algorithms (e.g., Jaro-Winkler, token-based matching) is needed, the `rapidfuzz` library is often a more modern and performant alternative. `rapidfuzz` also offers more flexible licensing (MIT).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-06T00:00:00.000Z","next_check":"2026-07-05T00:00:00.000Z"}