aboSamoor / polyglot

Multilingual text (NLP) processing toolkit
http://polyglot-nlp.com
Other
2.3k stars 337 forks source link

Symbol not found: __ZNK6icu_6114Transliterator12getTargetSetERNS_10UnicodeSetE in MacOS High Sierra, Python 3.6.5 #147

Closed GandhiNN closed 6 years ago

GandhiNN commented 6 years ago

Hi, this might seems like a recurring question regarding package installation, but i still could not run polyglot in my Mac machine after a seemingly successful installation of all the latest packages (from scratch) with the following traceback messages:

Gandhi@Quasimodo:~$ polyglot
Traceback (most recent call last):
  File "/usr/local/bin/polyglot", line 7, in <module>
    from polyglot.__main__ import main
  File "/usr/local/lib/python3.6/site-packages/polyglot/__main__.py", line 16, in <module>
    from icu import Locale
  File "/usr/local/lib/python3.6/site-packages/icu/__init__.py", line 37, in <module>
    from _icu import *
ImportError: dlopen(/usr/local/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so, 2): Symbol not found: __ZNK6icu_6114Transliterator12getTargetSetERNS_10UnicodeSetE
  Referenced from: /usr/local/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so
  Expected in: flat namespace
 in /usr/local/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so

I checked the content of _icu.cpython-36m-darwin.so (using cat) and it seems the symbol are listed there.

I am not sure if i have missed something during the installation or if there is any corrupted lib file; can you please help me point it out? Please find them below :

  1. Installed icu4c using homebrew (brew install icu4c)

  2. Exported all required environment variables before installing the pyicu package

    $ export ICU_VERSION=61
    $ export PYICU_INCLUDES=/usr/local/Cellar/icu4c/61.1/include
    $ export PYICU_LFLAGS=-L/usr/local/Cellar/icu4c/61.1/lib
    $ export LDFLAGS=-L/usr/local/Cellar/icu4c/61.1/lib
    $ export CPPFLAGS=-I/usr/local/Cellar/icu4c/61.1/include
    $ export DYLD_LIBRARY_PATH=-L/usr/local/Cellar/icu4c/61.1/lib
    $ export PKG_CONFIG_PATH=/usr/local/Cellar/icu4c/61.1/lib/pkgconfig
  3. Created symlinks toward icu4c using brew link icu4c --force

  4. Installed pyicu using pip (pip3 install pyicu)

  5. Installed polyglot using pip (pip3 install polyglot)

Side note : the same tracebacks were also generated when i tried from icu import Locale in the interactive shell(does this indicate that the icu4c installation on my Mac was actually unsuccessful somehow?).

FYI, i am using "vanilla" Python 3.6.5 and MacOS High Sierra 10.13.4

GandhiNN commented 6 years ago

Managed to solve this by reinstalling icu4c and building pyicu from scratch (and cleaned the build cache). I've wrote my workaround in details here https://stackoverflow.com/questions/50217214/import-error-for-icu-in-mac-and-ubuntu-although-pyicu-is-installed-correctly/50364835#50364835