4

I'm really struggling with polyglot, pyicu and icu4c - and it seems like I'm not the only one...

I'm running Mac OS High Sierra 10.13.6 and python3 with a virtualenv

Here are the steps I've taken, largely based on this article:

  1. Start from a new virtualenv
  2. Remove and re-install icu4c (v.62.1) with homebrew
  3. Check ICU_VERSION is "62.1"
  4. Do ln -s /usr/local/Cellar/icu4c/62.1/bin/icu-config /usr/local/bin/icu-config
  5. Download the pyicu tar file (2.1)
  6. Extract pyicu and edit setup.py as indicated in the linked article
  7. build and install pyicu

I see:

    Adding CXXFLAGS="-std=c++11 -I/usr/local/Cellar/icu4c/62.1/include" from /usr/local/bin/icu-config
    Adding LDFLAGS="-L/usr/local/Cellar/icu4c/62.1/lib -licui18n -licuuc -licudata" from /usr/local/bin/icu-config                    
    Installed/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyICU-2.1-py3.6-macosx-10.6-intel.egg
    ...
    Processing dependencies for PyICU==2.1
    Finished processing dependencies for PyICU==2.1

as expected.

  1. pip3 install polyglot

when I run my script I get the following:

File "/Users/Chris/MindWeb/Server/lib/python3.6/site-packages/polyglot/detect/__init__.py", line 1, in <module>
from .base import Detector, Language
File "/Users/Chris/MindWeb/Server/lib/python3.6/site-packages/polyglot/detect/base.py", line 11, in <module>
from icu import Locale
ModuleNotFoundError: No module named 'icu'

Unsurprising because there isn't actually an icu module in PATH.

If, instead of steps 5-7 I do pip3 install pyicu (which creates the icu folder), I get:

ImportError: dlopen(/Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so, 2): Symbol not found: __ZNK6icu_6214Transliterator12getTargetSetERNS_10UnicodeSetE
Referenced from: /Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so
Expected in: flat namespace
in /Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so

output from otool -L /Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so is:

/Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so:
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
bad_coder
  • 11,289
  • 20
  • 44
  • 72
Nahko
  • 78
  • 10
  • Did you manage to solve this? I have the exact same problem :( – Glennie Helles Sindholt Jan 15 '19 at 08:05
  • @GlennieHellesSindholt Actually yes. This method does work, the problem was to do with where the pyICU package was installed following the build from scratch (I hadn't realised it was outside the virtual environment). Are you sure that the correct version of pyICU is located in your venv PATH? – Nahko Jan 16 '19 at 15:04

1 Answers1

0

This answer on Github was not meant for this error specifically but provides a simple means for installing polyglot using conda and Python 3.6 (after solving the icu error I cam across others so this was helpful).

https://github.com/aboSamoor/polyglot/issues/80#issuecomment-417863726

Using a conda env you do the following:

conda install -c conda-forge pyicu morfessor icu -y && pip install pycld2 polyglot
Pelonomi Moiloa
  • 516
  • 5
  • 12