Last modified: Apr 03, 2025 By Alexander Williams

How to Install FuzzyWuzzy in Python

FuzzyWuzzy is a Python library for string matching. It helps compare strings and find similarities. This guide will show you how to install and use it.

What Is FuzzyWuzzy?

FuzzyWuzzy uses Levenshtein Distance to calculate string differences. It is useful for tasks like data cleaning and matching.

Prerequisites

Before installing FuzzyWuzzy, ensure you have Python installed. You can check by running python --version in your terminal.


python --version


Python 3.9.0

Install FuzzyWuzzy

FuzzyWuzzy can be installed using pip. Open your terminal and run the following command.


pip install fuzzywuzzy

If you face a ModuleNotFoundError, check our guide on how to solve ModuleNotFoundError.

Install Optional Dependencies

For faster performance, install the python-Levenshtein package. Run the following command.


pip install python-Levenshtein

Using FuzzyWuzzy

After installation, import the library in your Python script. Use the fuzz module for string comparisons.


from fuzzywuzzy import fuzz

# Compare two strings
similarity = fuzz.ratio("hello world", "hello python")
print(similarity)


60

Common Functions

FuzzyWuzzy provides several functions. The fuzz.ratio compares two strings. The fuzz.partial_ratio handles substrings.


# Partial ratio example
partial_similarity = fuzz.partial_ratio("hello", "hello world")
print(partial_similarity)


100

Process Module

The process module helps extract matches from a list. Use process.extract to find the best matches.


from fuzzywuzzy import process

choices = ["python", "java", "javascript"]
best_match = process.extract("py", choices, limit=2)
print(best_match)


[('python', 90), ('javascript', 30)]

Troubleshooting

If you encounter errors, ensure all dependencies are installed. Check your Python version and pip.

Conclusion

FuzzyWuzzy is a powerful tool for string matching in Python. Follow these steps to install and use it effectively.