I was trying to run the polyglot for my sentimental analysis. After a lot of struggling,, I successfully installed Polyglot and pyicu. However when I ran my program, it gave me this error, and I don't know how to fix it
    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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/icu/__init__.py)
The problem is package dependency. Run the following commands in order:
1- pip3 install pyicu
2- pip3 install pycld2
3- pip3 install morfessor
That should work for your case. Also, for more detailed answers, check this link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With