0

Why might I be getting a 'NameError: name 'ratio' is not defined' error when I attempt to use fuzzywuzzy in Pycharm. I have no issues using it in IDLE or python's 32-bit app.

I've reviewed similar topics of "works in idle but not pycharm"; however, those found related only to import name typos, utf encoding, and same function/file name. And I have ruled those out.

Example: Using: Python 3.7, Windows 10, FuzzyWuzzy version: 0.17

In IDLE -

    >>> from fuzzywuzzy import fuzz
    >>> fuzz.ratio('test', 'test2')
    >>> 89

In PYCHARM's python console:

    from fuzzywuzzy import fuzz
    fuzz.ratio('test', 'test2')

RETURNS:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\xx188\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fuzzywuzzy\utils.py", line 38, in decorator
    return func(*args, **kwargs)
  File "C:\Users\xx188\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fuzzywuzzy\utils.py", line 29, in decorator
    return func(*args, **kwargs)
  File "C:\Users\xx188\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fuzzywuzzy\utils.py", line 47, in decorator
    return func(*args, **kwargs)
  File "C:\Users\xx188\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fuzzywuzzy\fuzz.py", line 28, in ratio
    return utils.intr(100 * m.ratio())
  File "C:\Users\xx188\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fuzzywuzzy\StringMatcher.py", line 64, in ratio
    self._ratio = ratio(self._str1, self._str2)
NameError: name 'ratio' is not defined
SyntaxVoid
  • 2,501
  • 2
  • 15
  • 23
Rhelm
  • 11
  • 7
  • `ratio` there comes from `python-Levenshtein`. Do you have it installed on C:\Users\xx188\AppData\Local\Programs\Python\Python37-32? – Pavel Karateev Oct 31 '19 at 13:21
  • @PavelKarateev, i do not. Once I can get around my corporate firewall, I will add that to confirm. Thank you! – Rhelm Oct 31 '19 at 13:26

0 Answers0