Registry / ai-ml / editdistance

editdistance

JSON →
library0.8.1pypypi✓ verified 24d ago

Editdistance is a Python library providing a fast, C++ and Cython-optimized implementation of the Levenshtein (edit) distance. It efficiently calculates the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one sequence into the other. The library is suitable for applications requiring high-performance string similarity calculations, such as fuzzy matching, data cleaning, and natural language processing. The current version is 0.8.1, but the project's GitHub repository has been archived, indicating it is no longer actively maintained by the owner.

pip install editdistance
INSTALL
IMPORT
SIG · EDITDISTANCE
E
editdistance
ai-mlpythonv0.8.1
Install
1.6s avg
Import
Disk
20MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.8.1 · 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
glibc
py 3.10
✓ —
✓ 1.5s
py 3.11
✓ —
✓ 1.6s
py 3.12
✓ —
✓ 1.4s
py 3.13
✕ build_error
✕ build_error
py 3.9
✓ —
✓ 1.8s
20MB installed
● package 20MB
Code
Verified usage

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

eval
import editdistance editdistance.eval('string1', 'string2')
from editdistance import editdistance
The primary function `eval` is accessed directly from the imported `editdistance` module, not as a class instance.

This example demonstrates how to calculate the Levenshtein distance between two strings or two sequences of hashable objects using the `editdistance.eval()` function.

import editdistance # Calculate edit distance between two strings distance = editdistance.eval('kitten', 'sitting') print(f"Edit distance between 'kitten' and 'sitting': {distance}") # Works with any iterable of hashable objects (e.g., lists of words) distance_list = editdistance.eval(['spam', 'egg'], ['spam', 'ham']) print(f"Edit distance between ['spam', 'egg'] and ['spam', 'ham']: {distance_list}")
Debug
Known issues
breakingThe GitHub repository for `editdistance` (roy-ht/editdistance) was archived by the owner on June 30, 2025, making it read-only. This indicates that the library is no longer under active development or maintenance by its original creator, and new features or bug fixes are unlikely to be released.
fix
Be aware of the project's archived status. Consider alternative actively maintained libraries for new projects or if critical updates are required. For existing projects, pin the version to 'editdistance==0.8.1'.
affects: All versions post-June 2025
gotchaA separate, pure-Python library named `edit_distance` (with an underscore) exists on PyPI. It has a different API, is typically slower, and is not the C++/Cython optimized `editdistance` library. Importing the wrong one is a common mistake.
fix
Ensure you `pip install editdistance` (no underscore) and `import editdistance` (no underscore) to use the fast, Cython-backed implementation. Double-check your `requirements.txt` and import statements.
affects: All versions
gotchaVersions prior to `0.8.0` might produce incorrect results for very long sequences (e.g., those with length > 640) due to a bug that was fixed in version `0.8.0`.
fix
Upgrade to `editdistance==0.8.1` or newer to ensure correct calculations for all sequence lengths. If unable to upgrade, thoroughly test your application with long sequences on older versions.
affects: <0.8.0
gotchaAs of November 2023, `editdistance` version 0.8.1 did not have compatible binary wheels for Python 3.13 (cp313), potentially leading to installation failures in strict wheelhouse environments or requiring a build from source, which might have additional dependencies.
fix
Verify wheel availability for your specific Python version. If issues arise, consider creating a custom wheel or installing from a source distribution if build tools are available. Alternatively, constrain your Python version to those with available wheels or use a drop-in Python-only fallback if performance is not critical.
affects: 0.8.1 on Python 3.13+
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'editdistance'
This error occurs when the 'editdistance' package is not installed in the active Python environment or is installed incorrectly, so the Python interpreter cannot find it.
fix
Ensure the package is correctly installed by running: `pip install editdistance`. If using a virtual environment, activate it first. Verify installation with `pip show editdistance`.
ERROR: Microsoft Visual C++ 14.0 or greater is required.
The 'editdistance' library is implemented in C++/Cython and requires a C++ compiler (like Visual C++ Build Tools on Windows or GCC on Linux/macOS) to compile from source if a pre-compiled wheel isn't available for your specific Python version and operating system.
fix
On Windows, install 'Microsoft C++ Build Tools' from Visual Studio's website. On Linux, install `build-essential` (e.g., `sudo apt-get install build-essential`). On macOS, install Xcode Command Line Tools (`xcode-select --install`).
AttributeError: module 'editdistance' has no attribute 'eval'
This error usually means there's a name collision, where another file or module named 'editdistance.py' exists in your Python path, shadowing the actual installed 'editdistance' package. It can also occur if the installation is corrupted or an older version is present.
fix
Rename any local files or directories named `editdistance.py` or `editdistance` to avoid conflicts. Verify the correct package is installed and accessible by checking `pip show editdistance` and inspecting `sys.path` to ensure no conflicting paths are listed before the site-packages directory.
ERROR: Could not find a version that satisfies the requirement editdistance
This issue arises when `pip` cannot find a compatible pre-built binary wheel for your specific Python version and operating system, often leading back to the need to compile from source, which then requires C++ build tools.
fix
Ensure your Python version is compatible (e.g., Python >=3.8 for recent `editdistance` versions). If wheels are unavailable, you'll need a C++ compiler installed (as described for the 'Microsoft Visual C++' error). Consider using a virtual environment to manage dependencies or explicitly specifying an older `editdistance` version if known to have wheels for your setup (e.g., `pip install editdistance==0.8.0`).
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
Installing editdistance requires compiling C++ extensions, and the necessary C++ build tools are not installed on your Windows system.
fix
Install "Build Tools for Visual Studio" from Microsoft's website and ensure the "Desktop development with C++" workload is selected.
Upgrade
Version history
0.8.1latest on PyPI · released Feb 10, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
12
Meta
1
Amazon
1
OpenAI (training)
1
Resources
editdistance — pip install editdistance · libregistry