polyglot icon indicating copy to clipboard operation
polyglot copied to clipboard

ImportError: dlopen(/usr/local/lib/python2.7/site-packages/_icu.so, 2): Symbol not found:

Open loretoparisi opened this issue 5 years ago • 1 comments

On macOS I have installed icu4

export ICU_VERSION=63.1
export PYICU_INCLUDES=/usr/local/Cellar/icu4c/63.1/include
export PYICU_LFLAGS=-L/usr/local/Cellar/icu4c/63.1/lib
export PYICU_CFLAGS=-std=c++11
pip install pyicu

Source: https://gist.github.com/loretoparisi/294b8f536750a18746fc6f43f7859928

but when importing Transliterator I get

>>> from polyglot.transliteration import Transliterator
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/polyglot/transliteration/__init__.py", line 1, in <module>
    from .base import Transliterator
  File "/usr/local/lib/python2.7/site-packages/polyglot/transliteration/base.py", line 12, in <module>
    from ..load import load_transliteration_table
  File "/usr/local/lib/python2.7/site-packages/polyglot/load.py", line 16, in <module>
    from .downloader import downloader
  File "/usr/local/lib/python2.7/site-packages/polyglot/downloader.py", line 91, in <module>
    from polyglot.detect.langids import isoLangs
  File "/usr/local/lib/python2.7/site-packages/polyglot/detect/__init__.py", line 1, in <module>
    from .base import Detector, Language
  File "/usr/local/lib/python2.7/site-packages/polyglot/detect/base.py", line 11, in <module>
    from icu import Locale
  File "/usr/local/lib/python2.7/site-packages/icu/__init__.py", line 37, in <module>
    from _icu import *
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/_icu.so, 2): Symbol not found: __ZN6icu_638ByteSink15GetAppendBufferEiiPciPi
  Referenced from: /usr/local/lib/python2.7/site-packages/_icu.so
  Expected in: flat namespace
 in /usr/local/lib/python2.7/site-packages/_icu.so
>>>

I have also installed PyCu version 2.3.1 from sources editing the configuration for macOS:

INCLUDES = {
    'darwin': ['/usr/local/Cellar/icu4c/64.2'],
    'linux': [],
    'freebsd': ['/usr/local/include'],
    'win32': ['c:/icu/include'],
    'sunos5': [],
    'cygwin': [],
}

CFLAGS = {
    'darwin': ['-DPYICU_VER="%s"' %(VERSION), '-std=c++11'],
    'linux': [],
    'freebsd': ['-std=c++11'],
    'win32': ['/Zc:wchar_t', '/EHsc'],
    'sunos5': ['-std=c++11'],
    'cygwin': ['-D_GNU_SOURCE=1', '-std=c++11'],
}

LFLAGS = {
    'darwin': ['-L/usr/local/Cellar/icu4c/64.2/lib'],
    'linux': [],
    'freebsd': ['-L/usr/local/lib'],
    'win32': ['/LIBPATH:c:/icu/lib'],
    'sunos5': [],
    'cygwin': [],
}

LIBRARIES = {
    'darwin': ['/usr/local/Cellar/icu4c/64.2/lib'],
    'linux': [],
    'freebsd': ['icui18n', 'icuuc', 'icudata'],
    'win32': ['icuin', 'icuuc', 'icudt'],
    'sunos5': ['icui18n', 'icuuc', 'icudata'],
    'cygwin': ['icui18n', 'icuuc', 'icudata'],
}
ln -s /usr/local/Cellar/icu4c/64.2/bin/icu-config /usr/local/bin/icu-config
 CFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib python setup.py build
python setup.py install

resulting in

Installed /usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg
Processing dependencies for PyICU==2.3.1
Finished processing dependencies for PyICU==2.3.1

but I'm still getting the same error when importing the class.

Source: https://stackoverflow.com/questions/50217214/import-error-for-icu-in-mac-and-ubuntu-although-pyicu-is-installed-correctly/55905388#55905388

loretoparisi avatar Apr 29 '19 14:04 loretoparisi

I got the same error. This answer worked for me: https://stackoverflow.com/a/50364835/8815371 It occurred because Mac has a built-in ICU library. Linking the actual one fixes the problem.

bsamanvitha avatar Apr 05 '20 21:04 bsamanvitha