0

Polyglot seems installed, but can't run a simple test script from the official documentation.

I am running Python 3.9 on Windows 10 on a 64-bit machine. I used pip (pip install <package>) to install pycld2-0.41-cp39-cp39-win_amd64.whl and PyICU-2.6-cp39-cp39-win_amd64.whl from https://www.lfd.uci.edu/~gohlke/pythonlibs/, and also installed numpy (pip install numpy).

Here is my script (taken from https://polyglot.readthedocs.io/en/latest/Detection.html):

from polyglot.detect import Detector
from polyglot.utils import pretty_list
print(pretty_list(Detector.supported_languages()))

The output is

Traceback (most recent call last):
  File "C:\Users\briggs_w\Desktop\testPolyglot.py", line 3, in <module>
    print(pretty_list(Detector.supported_languages()))
  File "C:\Program Files\Python39\lib\site-packages\polyglot\utils.py", line 72, in pretty_list
    lang = lang.decode(u"utf-8")
AttributeError: 'str' object has no attribute 'decode'

So I don't know if I'm missing a library, but googling isn't getting me anything about how this error relates to polyglot's code.

Topological Sort
  • 2,733
  • 2
  • 27
  • 54
  • 1
    Works for me. What doesn't work is `pip install polyglot` on Python 3.9. It fails with an UnicodeDecodeError when building from source. Try the wheel at https://www.lfd.uci.edu/~gohlke/pythonlibs/#polyglot – cgohlke Feb 18 '21 at 19:53
  • Any idea why that worked? Write it as an answer and I will accept. Thanks! – Topological Sort Feb 22 '21 at 16:51
  • ``from polyglot.utils import pretty_list print(detector.supported_languages())`` produces a desired result with Win10, Python3.9 – brygid Aug 14 '21 at 13:41

0 Answers0