Search code examples
levenshtein-distance

ImportError: cannot import name 'ratio' from 'Levenshtein' (unknown location)


When I try import fuzzymatcher I get the error:

ImportError: cannot import name 'ratio' from 'Levenshtein' (unknown location)


Solution

  • Add the line #include <Python.h> to first line of the file _levenshtein.c inside of the Levenshtein folder.

    Then in fuzzywuzzy folder, replace from .StringMatcher import StringMatcher as SequenceMatcher with from Levenshtein import *.