gpt4 book ai didi

多语言导入错误 : cannot import name 'Locale' from 'icu'

转载 作者:行者123 更新时间:2023-12-04 11:30:15 26 4
gpt4 key购买 nike

我试图运行多语言来进行我的情感分析。经过一番挣扎,我成功安装了 Polyglot 和 pyicu。但是当我运行我的程序时,它给了我这个错误,我不知道如何修复它

    Traceback (most recent call last):
File "/Users/siyizhou/Documents/2020Fall/COMMresearch/code2/Pos_Neg.py", line 6, in <module>
from polyglot.text import Text
File "/usr/local/lib/python3.9/site-packages/polyglot/text.py", line 9, in <module>
from polyglot.detect import Detector, Language
File "/usr/local/lib/python3.9/site-packages/polyglot/detect/__init__.py", line 1, in <module>
from .base import Detector, Language
File "/usr/local/lib/python3.9/site-packages/polyglot/detect/base.py", line 11, in <module>
from icu import Locale
ImportError: cannot import name 'Locale' from 'icu' (/usr/local/lib/python3.9/site-
packages/icu/__init__.py)
siyizhou@Siyis-MBP code2 % polyglot download sentiment.en
Traceback (most recent call last):
File "/usr/local/bin/polyglot", line 33, in <module>
sys.exit(load_entry_point('polyglot==16.7.4', 'console_scripts', 'polyglot')())
File "/usr/local/bin/polyglot", line 25, in importlib_load_entry_point
return next(matches).load()
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/metadata.py", line 77, in load
module = import_module(match.group('module'))

File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/polyglot/__main__.py", line 16, in <module> from icu import Locale
ImportError: cannot import name 'Locale' from 'icu' (/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/icu/__init__.py)

最佳答案

问题是包依赖性。按顺序运行以下命令:
1- pip3 install pyicu2- pip3 install pycld23- pip3 install morfessor这应该适用于您的情况。此外,有关更详细的答案,请查看 this link

关于多语言导入错误 : cannot import name 'Locale' from 'icu' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64886067/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com