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:
ln -s /usr/local/Cellar/icu4c/62.1/bin/icu-config /usr/local/bin/icu-config
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.
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)
This method actually does work, the problem I was experiencing was related to the fact that the scratch install of pyICU was located outside of my python virtualenv and therefore not in $PATH
.
run all the build commands (whether pip
or setup.py
from the linked article) from inside your virtual environment
run echo $PATH
from within your python virtual environment, and ensure that the pyICU folder is located correctly.