published on Saturday November 18, 2017 00:11:00
I was having difficulties installing PyICU on macOS.
Normally, most packages I need can be installed by pip install <package_name>
without any troubles or even better, sometimes they come with Anaconda.
Sadly, I can't do that with PyICU and Anaconda.
What I've found so far
- https://anaconda.org/kalefranz/pyicu
- https://medium.com/data-science-cafe/install-polyglot-on-mac-3c90445abc1f
- http://python3.wannaphong.com/2015/03/python_9.html (Thai)
- https://naiwaen.debuggingsoft.com/2017/11/install-python-pyicu-anaconda/ (Thai)
- https://github.com/itkach/slob/issues/12#issuecomment-242989583
I followed the last link and got PyICU installed successfully.
I also tried to install it with Anaconda and here are the steps to install PyICU on macOS with Anaconda.
If you can't install with Anaconda, just follow the GitHub link above.
Step 1: Install icu4c using Homebrew
$ brew install icu4c
You will see the caveat like this:
==> Caveats
This formula 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 this software first in your PATH run:
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/icu4c/lib
CPPFLAGS: -I/usr/local/opt/icu4c/include
For pkg-config to find this software you may need to set:
PKG_CONFIG_PATH: /usr/local/opt/icu4c/lib/pkgconfig
Step 2: Build and Install PyICU library from source
# Download PyICU-1.9.8.tar.gz from https://pypi.python.org/pypi/PyICU/
$ tar xvf PyICU-1.9.8.tar.gz
$ cd PyICU-1.9.8
$ LDFLAGS=-L/usr/local/opt/icu4c/lib CPPFLAGS=-I/usr/local/opt/icu4c/include python setup.py build
$ python setup.py install
Environment
- macOS Sierra 10.12.6
- Python 3.6.1 :: Anaconda custom (x86_64)