问题描述
polyglot 似乎已安装,但无法运行官方文档中的简单测试脚本。
我在 64 位机器上的 Windows 10 上运行 Python 3.9。我使用 pip (pip install <package>
) 从 https://www.lfd.uci.edu/~gohlke/pythonlibs/ 安装 pycld2-0.41-cp39-cp39-win_amd64.whl
和 PyICU-2.6-cp39-cp39-win_amd64.whl
,还安装了 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'
所以我不知道我是否缺少一个库,但是谷歌搜索并没有让我了解这个错误与多语言代码的关系。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)