[Solved] Pip install icu failed: Command “python setup.py egg_info” failed with error code 1 in

problem

Failed to install icu via pip under Mac.

Solution and reason

The cause of the problem is that a certain line of code in the icu library cannot find a file and cannot get ICU_VERSIONthe value.

# Install icu
brew install icu4c

# check newest version
ls /usr/local/Cellar/icu4c/

# Edit pyicu installer to work
git clone https://github.com/ovalhub/pyicu.git

# edit setup.py not to query for the version, i.e. change
# ICU_VERSION = subprocess.check_output(('icu-config', '--version')).strip()
# to whatever your version is, e.g.
# ICU_VERSION = '57'

# Install pyicu
env LDFLAGS=-L/usr/local/opt/icu4c/lib CPPFLAGS=-I/usr/local/opt/icu4c/include DYLD_LIBRARY_PATH=-L/usr/local/opt/icu4c/lib python setup.py build
env LDFLAGS=-L/usr/local/opt/icu4c/lib CPPFLAGS=-I/usr/local/opt/icu4c/include DYLD_LIBRARY_PATH=-L/usr/local/opt/icu4c/lib sudo python setup.py install

# Change DYLD_LIBRARY_PATH (not sure if req'd)
DYLD_LIBRARY_PATH=/usr/local/Cellar/icu4c/57.1/:$DYLD_LIBRARY_PATH
echo $DYLD_LIBRARY_PATH

# Icu works now from python, and you can proceed with polyglot
$ python
>>> import icu
$ pip install polyglot
$ python
>>> import polyglot

reference

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *