Polyglot 似乎已安装,但无法从官方文档运行简单的测试脚本。
我在 64 位机器上的 Windows 10 上运行 Python 3.9。我使用 pip ( pip install <package>
) 安装pycld2-0.41-cp39-cp39-win_amd64.whl
并PyICU-2.6-cp39-cp39-win_amd64.whl
从https://www.lfd.uci.edu/~gohlke/pythonlibs/安装,还安装了 numpy ( pip install numpy
)。
这是我的脚本(取自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()))
输出是
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'
所以我不知道我是否错过了一个库,但是谷歌搜索并没有让我了解这个错误与多语言代码的关系。