module 'thefuzz' has no attribute 'partial_ratio' and other odd errors

56 Views Asked by At

Been trying to use thefuzz to compare two different lists, and got the above error, which doesn't seem right. I've commented everything else out in my code except the below two test lines and still getting the error. I've also tried fuzz.ratio, fuzz.token_sort_ratio and fuzz.token_set_ratio and getting an error every time.

import thefuzz as fuzz

fuzz.partial_ratio("fuzzy was a bear", "wuzzy fuzzy was a bear")
1

There are 1 best solutions below

0
lostbard On BEST ANSWER

You want

import thefuzz.fuzz as fuzz

Or

from thefuzz import fuzz

As that is where the functions you want are found

The usage section of the thefuzz readme (https://github.com/seatgeek/thefuzz/blob/master/README.rst) suggests:

from thefuzz import fuzz
from thefuzz import process