ovalhub / pyicu

The PyICU project repository has moved to https://pyicu.org.
Other
133 stars 50 forks source link

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

Closed loretoparisi closed 5 years ago

loretoparisi commented 5 years ago

On macOS, python 2.7.16 I have installed icu4

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

but when importing icu I get

>>> import pyicu
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pyicu
>>> import pycu
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pycu
>>> from icu import UnicodeString, Locale
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "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

ovalhub commented 5 years ago

Your LIBRARIES entry for darwin is wrong, it's not a path but the list of libraries to link against. If your ICU install has icu_config (and the PyICU build can find it), you don't need to set anything in setup.py, the defaults work.

Andi..

On Apr 29, 2019, at 07:29, Loreto Parisi notifications@github.com wrote:

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 but when importing icu I get

import pyicu Traceback (most recent call last): File "", line 1, in ImportError: No module named pyicu import pycu Traceback (most recent call last): File "", line 1, in ImportError: No module named pycu from icu import UnicodeString, Locale Traceback (most recent call last): File "", line 1, in File "icu/init.py", line 37, in 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

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

loretoparisi commented 5 years ago

@ovalhub I did some changes, got a different error...

/usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg/_icu.py:3: UserWarning: Module _icu was already imported from /usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg/_icu.pyc, but /Users/loretoparisi/Documents/Projects/AI/pyicu is being added to sys.path

full stacktrace:

ip-192-168-22-127:pyicu loretoparisi$ python setup.py install

Building PyICU 2.3.1 for ICU 64.2

running install
running bdist_egg
running egg_info
writing PyICU.egg-info/PKG-INFO
writing top-level names to PyICU.egg-info/top_level.txt
writing dependency_links to PyICU.egg-info/dependency_links.txt
reading manifest file 'PyICU.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'PyICU.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.14-x86_64/egg
running install_lib
running build_py
running build_ext
creating build/bdist.macosx-10.14-x86_64/egg
copying build/lib.macosx-10.14-x86_64-2.7/_icu.so -> build/bdist.macosx-10.14-x86_64/egg
copying build/lib.macosx-10.14-x86_64-2.7/PyICU.py -> build/bdist.macosx-10.14-x86_64/egg
creating build/bdist.macosx-10.14-x86_64/egg/icu
copying build/lib.macosx-10.14-x86_64-2.7/icu/__init__.py -> build/bdist.macosx-10.14-x86_64/egg/icu
byte-compiling build/bdist.macosx-10.14-x86_64/egg/PyICU.py to PyICU.pyc
byte-compiling build/bdist.macosx-10.14-x86_64/egg/icu/__init__.py to __init__.pyc
creating stub loader for _icu.so
byte-compiling build/bdist.macosx-10.14-x86_64/egg/_icu.py to _icu.pyc
creating build/bdist.macosx-10.14-x86_64/egg/EGG-INFO
copying PyICU.egg-info/PKG-INFO -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO
copying PyICU.egg-info/SOURCES.txt -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO
copying PyICU.egg-info/dependency_links.txt -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO
copying PyICU.egg-info/top_level.txt -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO
writing build/bdist.macosx-10.14-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating 'dist/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg' and adding 'build/bdist.macosx-10.14-x86_64/egg' to it
removing 'build/bdist.macosx-10.14-x86_64/egg' (and everything under it)
Processing PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg
Copying PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg to /usr/local/lib/python2.7/site-packages
Adding PyICU 2.3.1 to easy-install.pth file

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
ip-192-168-22-127:pyicu loretoparisi$ python -c "import icu"
/usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg/_icu.py:3: UserWarning: Module _icu was already imported from /usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg/_icu.pyc, but /Users/loretoparisi/Documents/Projects/AI/pyicu is being added to sys.path
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "icu/__init__.py", line 37, in <module>
    from _icu import *
  File "build/bdist.macosx-10.14-x86_64/egg/_icu.py", line 7, in <module>
  File "build/bdist.macosx-10.14-x86_64/egg/_icu.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so, 2): Symbol not found: __ZN6icu_648ByteSink15GetAppendBufferEiiPciPi
  Referenced from: /Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so
  Expected in: flat namespace
 in /Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so
ovalhub commented 5 years ago

On Apr 29, 2019, at 07:56, Loreto Parisi notifications@github.com wrote:

I did some changes, got a different error...

"some changes" ?

Is the icu-config program found by the build ? What does 'which icu-config' return ?

[UPDATE]

ip-192-168-22-127:pyicu loretoparisi$ python setup.py install

Building PyICU 2.3.1 for ICU 64.2

running install running bdist_egg running egg_info writing PyICU.egg-info/PKG-INFO writing top-level names to PyICU.egg-info/top_level.txt writing dependency_links to PyICU.egg-info/dependency_links.txt reading manifest file 'PyICU.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'PyICU.egg-info/SOURCES.txt' installing library code to build/bdist.macosx-10.14-x86_64/egg running install_lib running build_py running build_ext creating build/bdist.macosx-10.14-x86_64/egg copying build/lib.macosx-10.14-x86_64-2.7/_icu.so -> build/bdist.macosx-10.14-x86_64/egg copying build/lib.macosx-10.14-x86_64-2.7/PyICU.py -> build/bdist.macosx-10.14-x86_64/egg creating build/bdist.macosx-10.14-x86_64/egg/icu copying build/lib.macosx-10.14-x86_64-2.7/icu/init.py -> build/bdist.macosx-10.14-x86_64/egg/icu byte-compiling build/bdist.macosx-10.14-x86_64/egg/PyICU.py to PyICU.pyc byte-compiling build/bdist.macosx-10.14-x86_64/egg/icu/init.py to init.pyc creating stub loader for _icu.so byte-compiling build/bdist.macosx-10.14-x86_64/egg/_icu.py to _icu.pyc creating build/bdist.macosx-10.14-x86_64/egg/EGG-INFO copying PyICU.egg-info/PKG-INFO -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO copying PyICU.egg-info/SOURCES.txt -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO copying PyICU.egg-info/dependency_links.txt -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO copying PyICU.egg-info/top_level.txt -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO writing build/bdist.macosx-10.14-x86_64/egg/EGG-INFO/native_libs.txt zip_safe flag not set; analyzing archive contents... creating 'dist/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg' and adding 'build/bdist.macosx-10.14-x86_64/egg' to it removing 'build/bdist.macosx-10.14-x86_64/egg' (and everything under it) Processing PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg Copying PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg to /usr/local/lib/python2.7/site-packages Adding PyICU 2.3.1 to easy-install.pth file

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 ip-192-168-22-127:pyicu loretoparisi$ python -c "import icu" /usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg/_icu.py:3: UserWarning: Module _icu was already imported from /usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg/_icu.pyc, but /Users/loretoparisi/Documents/Projects/AI/pyicu is being added to sys.path Traceback (most recent call last): File "", line 1, in File "icu/init.py", line 37, in from _icu import * File "build/bdist.macosx-10.14-x86_64/egg/_icu.py", line 7, in File "build/bdist.macosx-10.14-x86_64/egg/_icu.py", line 6, in bootstrap ImportError: dlopen(/Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so, 2): Symbol not found: __ZN6icu_648ByteSink15GetAppendBufferEiiPciPi Referenced from: /Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so Expected in: flat namespace in /Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

ovalhub commented 5 years ago

As a clue to the error you're seeing: it often means that you are compiling PyICU against a different version of ICU (headers) than you're then linking against (libraries). This can happen when you have multiple versions of ICU installed.

I recommend you:

Andi..

On Apr 29, 2019, at 07:56, Loreto Parisi notifications@github.com wrote:

I did some changes, got a different error...

[UPDATE]

ip-192-168-22-127:pyicu loretoparisi$ python setup.py install

Building PyICU 2.3.1 for ICU 64.2

running install running bdist_egg running egg_info writing PyICU.egg-info/PKG-INFO writing top-level names to PyICU.egg-info/top_level.txt writing dependency_links to PyICU.egg-info/dependency_links.txt reading manifest file 'PyICU.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'PyICU.egg-info/SOURCES.txt' installing library code to build/bdist.macosx-10.14-x86_64/egg running install_lib running build_py running build_ext creating build/bdist.macosx-10.14-x86_64/egg copying build/lib.macosx-10.14-x86_64-2.7/_icu.so -> build/bdist.macosx-10.14-x86_64/egg copying build/lib.macosx-10.14-x86_64-2.7/PyICU.py -> build/bdist.macosx-10.14-x86_64/egg creating build/bdist.macosx-10.14-x86_64/egg/icu copying build/lib.macosx-10.14-x86_64-2.7/icu/init.py -> build/bdist.macosx-10.14-x86_64/egg/icu byte-compiling build/bdist.macosx-10.14-x86_64/egg/PyICU.py to PyICU.pyc byte-compiling build/bdist.macosx-10.14-x86_64/egg/icu/init.py to init.pyc creating stub loader for _icu.so byte-compiling build/bdist.macosx-10.14-x86_64/egg/_icu.py to _icu.pyc creating build/bdist.macosx-10.14-x86_64/egg/EGG-INFO copying PyICU.egg-info/PKG-INFO -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO copying PyICU.egg-info/SOURCES.txt -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO copying PyICU.egg-info/dependency_links.txt -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO copying PyICU.egg-info/top_level.txt -> build/bdist.macosx-10.14-x86_64/egg/EGG-INFO writing build/bdist.macosx-10.14-x86_64/egg/EGG-INFO/native_libs.txt zip_safe flag not set; analyzing archive contents... creating 'dist/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg' and adding 'build/bdist.macosx-10.14-x86_64/egg' to it removing 'build/bdist.macosx-10.14-x86_64/egg' (and everything under it) Processing PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg Copying PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg to /usr/local/lib/python2.7/site-packages Adding PyICU 2.3.1 to easy-install.pth file

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 ip-192-168-22-127:pyicu loretoparisi$ python -c "import icu" /usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg/_icu.py:3: UserWarning: Module _icu was already imported from /usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg/_icu.pyc, but /Users/loretoparisi/Documents/Projects/AI/pyicu is being added to sys.path Traceback (most recent call last): File "", line 1, in File "icu/init.py", line 37, in from _icu import * File "build/bdist.macosx-10.14-x86_64/egg/_icu.py", line 7, in File "build/bdist.macosx-10.14-x86_64/egg/_icu.py", line 6, in bootstrap ImportError: dlopen(/Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so, 2): Symbol not found: __ZN6icu_648ByteSink15GetAppendBufferEiiPciPi Referenced from: /Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so Expected in: flat namespace in /Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

loretoparisi commented 5 years ago

@ovalhub so I have checked it out and it seems I have installed this one from brew:

 /usr/local/Cellar/icu4c/64.2

So, asssumed that is correct, I have reverted to the master:

Saved working directory and index state WIP on master: 983144b   - fixed build error with ICU 61, ICU 62   - release PyICU 2.3.1

and tried again

ip-192-168-22-127:pyicu loretoparisi$ python setup.py build
(running 'icu-config --version')

Building PyICU 2.3.1 for ICU 64.2

(running 'icu-config --cxxflags --cppflags')
Adding CFLAGS="-std=c++11 -I/usr/local/Cellar/icu4c/64.2/include" from /usr/local/bin/icu-config
(running 'icu-config --ldflags')
Adding LFLAGS="-L/usr/local/Cellar/icu4c/64.2/lib -licui18n -licuuc -licudata" from /usr/local/bin/icu-config
running build
running build_py
running build_ext

and

python setup.py install
...
PyICU 2.3.1 is already the active version in easy-install.pth

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 get again an error:

ip-192-168-22-127:pyicu loretoparisi$ python -c "import icu"
/usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg/_icu.py:3: UserWarning: Module _icu was already imported from /usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg/_icu.pyc, but /Users/loretoparisi/Documents/Projects/AI/pyicu is being added to sys.path
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "icu/__init__.py", line 37, in <module>
    from _icu import *
  File "build/bdist.macosx-10.14-x86_64/egg/_icu.py", line 7, in <module>
  File "build/bdist.macosx-10.14-x86_64/egg/_icu.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so, 2): Symbol not found: __ZN6icu_648ByteSink15GetAppendBufferEiiPciPi
  Referenced from: /Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so
  Expected in: flat namespace
 in /Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so
ovalhub commented 5 years ago

On Apr 29, 2019, at 08:47, Loreto Parisi notifications@github.com wrote:

@ovalhub so I have checked it out and it seems I have installed this one from brew:

/usr/local/Cellar/icu4c/64.2 So, asssumed that is correct, I have reverted to the master:

Saved working directory and index state WIP on master: 983144b - fixed build error with ICU 61, ICU 62 - release PyICU 2.3.1 and tried again

ip-192-168-22-127:pyicu loretoparisi$ python setup.py build (running 'icu-config --version')

Building PyICU 2.3.1 for ICU 64.2

(running 'icu-config --cxxflags --cppflags') Adding CFLAGS="-std=c++11 -I/usr/local/Cellar/icu4c/64.2/include" from /usr/local/bin/icu-config (running 'icu-config --ldflags') Adding LFLAGS="-L/usr/local/Cellar/icu4c/64.2/lib -licui18n -licuuc -licudata" from /usr/local/bin/icu-config running build running build_py running build_ext and

python setup.py install ... PyICU 2.3.1 is already the active version in easy-install.pth

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 get again an error:

Carefully read the entire error message below and cleanup your installs so you are not getting _icu from both /usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg/_icu.py and /Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so

Andi..

ip-192-168-22-127:pyicu loretoparisi$ python -c "import icu" /usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg/_icu.py:3: UserWarning: Module _icu was already imported from /usr/local/lib/python2.7/site-packages/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg/_icu.pyc, but /Users/loretoparisi/Documents/Projects/AI/pyicu is being added to sys.path Traceback (most recent call last): File "", line 1, in File "icu/init.py", line 37, in from _icu import * File "build/bdist.macosx-10.14-x86_64/egg/_icu.py", line 7, in File "build/bdist.macosx-10.14-x86_64/egg/_icu.py", line 6, in bootstrap ImportError: dlopen(/Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so, 2): Symbol not found: __ZN6icu_648ByteSink15GetAppendBufferEiiPciPi Referenced from: /Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so Expected in: flat namespace in /Users/loretoparisi/Library/Caches/Python-Eggs/PyICU-2.3.1-py2.7-macosx-10.14-x86_64.egg-tmp/_icu.so — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

loretoparisi commented 5 years ago

[UPDATE] Sorry for the long thread, here it is a cleaned up example:

ip-192-168-22-127:AI loretoparisi$ brew uninstall --ignore-dependencies icu4c
Uninstalling /usr/local/Cellar/icu4c/64.2... (257 files, 69.2MB)
ip-192-168-22-127:AI loretoparisi$ brew install icu4c
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/icu4c-64.2.mojave.bottle.tar.gz
Already downloaded: /Users/loretoparisi/Library/Caches/Homebrew/downloads/85517172585f53ec6345bbab70673ae252f1fb92de862d669bd47db314e40162--icu4c-64.2.mojave.bottle.tar.gz
==> Pouring icu4c-64.2.mojave.bottle.tar.gz
==> Caveats
icu4c is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile

For compilers to find icu4c you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

==> Summary
🍺  /usr/local/Cellar/icu4c/64.2: 257 files, 69.2MB
ip-192-168-22-127:AI loretoparisi$ ls /usr/local/Cellar/icu4c/
64.2
ip-192-168-22-127:AI loretoparisi$ export ICU_VERSION=64
ip-192-168-22-127:AI loretoparisi$ export PYICU_INCLUDES=/usr/local/Cellar/icu4c/64.2/include
ip-192-168-22-127:AI loretoparisi$ export PYICU_LFLAGS=-L/usr/local/Cellar/icu4c/64.2/lib
ip-192-168-22-127:AI loretoparisi$ python -c "import icu"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named icu
ip-192-168-22-127:AI loretoparisi$ pip install pyicu
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting pyicu
Installing collected packages: pyicu
Successfully installed pyicu-2.3.1
ip-192-168-22-127:AI loretoparisi$ python -c "import icu"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  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
ovalhub commented 5 years ago

In my last reply, I told you about the two versions of _icu.so you seem to have installed and you're replying with a log of how you install with homebrew. Am I even making sense ?

These _icu.so files are various versions of your PyICU build attempts, not ICU's binaries.

Andi..

On Mon, 29 Apr 2019, Loreto Parisi wrote:

[UPDATE] Sorry for the long thread, here it is a cleaned up example:

ip-192-168-22-127:AI loretoparisi$ brew uninstall --ignore-dependencies icu4c
Uninstalling /usr/local/Cellar/icu4c/64.2... (257 files, 69.2MB)
ip-192-168-22-127:AI loretoparisi$ brew install icu4c
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/icu4c-64.2.mojave.bottle.tar.gz
Already downloaded: /Users/loretoparisi/Library/Caches/Homebrew/downloads/85517172585f53ec6345bbab70673ae252f1fb92de862d669bd47db314e40162--icu4c-64.2.mojave.bottle.tar.gz
==> Pouring icu4c-64.2.mojave.bottle.tar.gz
==> Caveats
icu4c is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH run:
 echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
 echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile

For compilers to find icu4c you may need to set:
 export LDFLAGS="-L/usr/local/opt/icu4c/lib"
 export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:
 export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

==> Summary
?  /usr/local/Cellar/icu4c/64.2: 257 files, 69.2MB
ip-192-168-22-127:AI loretoparisi$ ls /usr/local/Cellar/icu4c/
64.2
ip-192-168-22-127:AI loretoparisi$ export ICU_VERSION=64
ip-192-168-22-127:AI loretoparisi$ export PYICU_INCLUDES=/usr/local/Cellar/icu4c/64.2/include
ip-192-168-22-127:AI loretoparisi$ export PYICU_LFLAGS=-L/usr/local/Cellar/icu4c/64.2/lib
ip-192-168-22-127:AI loretoparisi$ python -c "import icu"
Traceback (most recent call last):
 File "<string>", line 1, in <module>
ImportError: No module named icu
ip-192-168-22-127:AI loretoparisi$ pip install pyicu
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting pyicu
Installing collected packages: pyicu
Successfully installed pyicu-2.3.1
ip-192-168-22-127:AI loretoparisi$ python -c "import icu"
Traceback (most recent call last):
 File "<string>", line 1, in <module>
 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

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/ovalhub/pyicu/issues/101#issuecomment-487657781

loretoparisi commented 5 years ago

@ovalhub thank you Andi, I will try to get rid then to clean up all attempts. Thank you very much.

loretoparisi commented 5 years ago

So thank you very much, could you be so kind to confirm me these steps:

  1. I have removed the current PyICU install first - pip uninstall pyicu

    Skipping icu as it is not installed.
    ip-192-168-22-127:AI loretoparisi$ pip uninstall pyicu
    DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
    Uninstalling PyICU-2.3.1:
    Would remove:
    /usr/local/lib/python2.7/site-packages/PyICU-2.3.1.dist-info/*
    /usr/local/lib/python2.7/site-packages/PyICU.py
    /usr/local/lib/python2.7/site-packages/_icu.so
    /usr/local/lib/python2.7/site-packages/icu/*
    Proceed (y/n)? y
    Successfully uninstalled PyICU-2.3.1
  2. I have removed any previous installation of icu4c, since I'm using Homebrew the command was brew uninstall --ignore-dependencies icu4c, so therefore I have a No such keg: /usr/local/Cellar/icu4c on my macOS at this point.

  3. Cleaning the Homebrew cache, to avoid any possibile previous install - brew cleanup

  4. install icu4c again - brew install icu4c & brew link icu4c --force

    
    ip-192-168-22-157:~ loretoparisi$ brew install icu4c
    Updating Homebrew...
    ==> Auto-updated Homebrew!
    Updated 2 taps (homebrew/core and homebrew/cask).
    ==> Updated Formulae
    node ✔                    diff-pdf                  pdftoipe                  pmd                       sipsak                    sourcekitten              vulkan-headers
    poppler ✔                 joplin                    plantuml                  shpotify                  sonobuoy                  txr                       youtube-dl

==> Downloading https://homebrew.bintray.com/bottles/icu4c-64.2.mojave.bottle.tar.gz Already downloaded: /Users/loretoparisi/Library/Caches/Homebrew/downloads/85517172585f53ec6345bbab70673ae252f1fb92de862d669bd47db314e40162--icu4c-64.2.mojave.bottle.tar.gz ==> Pouring icu4c-64.2.mojave.bottle.tar.gz ==> Caveats icu4c is keg-only, which means it was not symlinked into /usr/local, because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH run: echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile

For compilers to find icu4c you may need to set: export LDFLAGS="-L/usr/local/opt/icu4c/lib" export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

==> Summary 🍺 /usr/local/Cellar/icu4c/64.2: 257 files, 69.2MB


4. install and skip cache - **CFLAGS=-I/usr/local/opt/icu4c/include PYICU_LFLAGS=-L/usr/local/Cellar/icu4c/64.2/lib PYICU_CFLAGS="-std=c++11" ICU_VERSION=64.2 pip --no-cache-dir install PyICU**

ip-192-168-22-157:~ loretoparisi$ CFLAGS=-I/usr/local/opt/icu4c/include PYICU_LFLAGS=-L/usr/local/Cellar/icu4c/64.2/lib PYICU_CFLAGS="-std=c++11" ICU_VERSION=64.2 pip --no-cache-dir install PyICU DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Collecting PyICU Downloading https://files.pythonhosted.org/packages/e9/35/211ffb949c68e688ade7d40426de030a24eaec4b6c45330eeb9c0285f43a/PyICU-2.3.1.tar.gz (214kB) 100% |████████████████████████████████| 215kB 921kB/s Installing collected packages: PyICU Running setup.py install for PyICU ... done Successfully installed PyICU-2.3.1


5. check the static library is there in **/usr/local/lib/python2.7/site-packages/_icu.so **

ip-192-168-22-157:~ loretoparisi$ ls -l /usr/local/lib/python2.7/site-packages/_icu.so -rwxr-xr-x 1 loretoparisi admin 1282908 30 Apr 15:09 /usr/local/lib/python2.7/site-packages/_icu.so


6. check if the symbol `__ZN6icu_648ByteSink15GetAppendBufferEiiPciPi` is there! **nm /usr/local/lib/python2.7/site-packages/_icu.so | grep __ZN6icu_648ByteSink15GetAppendBufferEiiPciPi**

ip-192-168-22-157:~ loretoparisi$ nm /usr/local/lib/python2.7/site-packages/_icu.so | grep __ZN6icu_648ByteSink15GetAppendBufferEiiPciPi U __ZN6icu_648ByteSink15GetAppendBufferEiiPciPi



7. I run and export the library path **DYLD_LIBRARY_PATH=/usr/local/Cellar/icu4c/64.2/lib/ python -c "import icu"**, At this point I do not know where I am wrong, since I get the same error **Symbol not found: __ZN6icu_648ByteSink15GetAppendBufferEiiPciPi** even if that symbol is there!

Thank you very much for your help.
loretoparisi commented 5 years ago

[UPDATE]

Ok, it worked ONLY in this way!

curl -LO http://download.icu-project.org/files/icu4c/55.1/icu4c-55_1-src.tgz
tar xzvf icu4c-55_1-src.tgz
cd icu/source
chmod +x runConfigureICU configure install-sh
./runConfigureICU MacOSX
make
sudo make install
sudo cp -r common/unicode /usr/local/include/

and then

ICU_VERSION=55.1 pip --no-cache-dir install PyICU
python -c "from icu import Locale; locale = Locale('ta_TAM'); name = locale.getDisplayName(); print(name)"
tamil (TAM)

It's crazy, I do not know why, but it worked from the sources with the version 55.1. I think there is an issue somewhere in any case, because there are a lot of complains. Thank you.

ovalhub commented 5 years ago

On Apr 30, 2019, at 07:40, Loreto Parisi notifications@github.com wrote:

[UPDATE]

Ok, it worked ONLY in this way!

curl -LO http://download.icu-project.org/files/icu4c/55.1/icu4c-55_1-src.tgz Version 55.1 is old, you should use version 64.2. tar xzvf icu4c-55_1-src.tgz cd icu/source chmod +x runConfigureICU configure install-sh ./runConfigureICU MacOSX make sudo make install Good, no homebrew. sudo cp -r common/unicode /usr/local/include/ This is not necessary, the install step above takes care of it. and then

ICU_VERSION=55.1 pip --no-cache-dir I suspect --no-cache-dir gets you past the earlier error I told you about yesterday.

Also, you do not need to set ICU_VERSION since you installed ICU from the official sources and they come with icu-config.

install PyICU python -c "from icu import Locale; locale = Locale('ta_TAM'); name = locale.getDisplayName(); print(name)" tamil (TAM) It's crazy, I do not know why,

There is nothing crazy, you need to know what you're doing, read error messages, and know what's on your machine. but it worked from the sources with the version 55.1. I think there is an issue somewhere in any case, because there are a lot of complains. Thank you.

Yes, there is an issue somewhere.

While using 'pip' and 'homebrew' make it easier to install things, they also make it harder to understand what goes wrong when it does.

You should install ICU the way you now did it, but the latest version. You should download the PyICU 2.3.1 egg from PyPI and install it with python setup.py build install

To better understand what you're doing, you should continue with this install until you have ICU 64.2 + PyICU 2.3.1 installed without setting any env vars or changes to setup.py.

Andi..

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

loretoparisi commented 5 years ago

Thank you very much for your help!