Install & Compatibility
Where this runs
tested against v0.3.4 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.220s · 17.8MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.186s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
fuzzy_match
✓ from pfzy import fuzzy_match
FzyScorer
✓ from pfzy import FzyScorer
Used for direct scoring without options filtering.
SubstringScorer
✓ from pfzy import SubstringScorer
Used for exact substring matching.
Demonstrates how to use the `fuzzy_match` function asynchronously to find fuzzy matches and their indices from a list of options based on a given query.
import asyncio
from pfzy import fuzzy_match
async def main():
options = ["apple", "banana", "apricot", "grape"]
query = "ap"
results = await fuzzy_match(query, options)
print(results)
if __name__ == "__main__":
asyncio.run(main())
Debug
Known issues
gotchapfzy strictly requires Python versions between `3.7` and `3.9.x` (specifically tested and uploaded with Python 3.9.5, though PyPI metadata states `<4.0`). Users on Python 3.10+ or Python 3.6 and below may encounter installation or runtime issues.fixEnsure your Python environment is within the `Python >=3.7,<4.0` range for optimal compatibility.
affects: All versions of pfzy
gotchaThe core `fuzzy_match` function is an `async` function. It must be called using `await` within an `async` context (e.g., inside an `async def` function) or executed directly using `asyncio.run()` in a synchronous script. Failing to do so will result in a `coroutine object` being returned, not the actual results.fixWrap calls to `fuzzy_match` with `asyncio.run(fuzzy_match(...))` for synchronous scripts, or `await fuzzy_match(...)` within existing `async` functions.
affects: All versions of pfzy
gotchapfzy is a port of the `fzy` algorithm, primarily designed for interactive fuzzy *finder applications* where matching scores and *indices* are crucial for highlighting. It is not a general-purpose string similarity library like `fuzzywuzzy` or `rapidfuzz` and may behave differently or offer different features than expected if used as a direct replacement for those.fixUnderstand the `fzy` algorithm's scoring characteristics and ensure it aligns with your specific fuzzy matching requirements, especially if you need matching indices for UI applications.
affects: All versions of pfzy
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pfzy'
The 'pfzy' library is not installed in the current Python environment or there is a typo in the import statement.
fixInstall the library using pip: `pip install pfzy`
AttributeError: module 'pfzy' has no attribute 'fuzzy_match'
This typically occurs when trying to access `pfzy.fuzzy_match` after `import pfzy`, or if there's a typo in the function name. The `fuzzy_match` function is intended to be imported directly.
fixUse the direct import statement: `from pfzy import fuzzy_match`
RuntimeError: no running event loop
The `pfzy.fuzzy_match` function is an asynchronous coroutine and must be run within an `asyncio` event loop. This error occurs when you call it directly in synchronous code without managing the event loop.
fixExecute the asynchronous function using `asyncio.run()`: `import asyncio; from pfzy import fuzzy_match; result = asyncio.run(fuzzy_match('query', ['target']))` TypeError: fuzzy_match() missing 1 required positional argument: 'choices'
The `fuzzy_match` function requires two positional arguments: the query string and a list of choices to match against. This error indicates one or both were not provided.
fixEnsure both the `query` string and the `choices` list are passed to the function: `fuzzy_match('apple', ['pineapple', 'grape'])` Upgrade
Version history
0.3.4latest on PyPI · released Jan 28, 2022
Audit
Dependencies
No dependency data recorded yet.