Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Installation instructions for libicu-dev, PyICU, libpostal, pypostal on Mac OS X 10.14+

Installing PyICU, libpostal, pypostal on Mac OS X 10.14+

libicu-dev (PyICU dependency)

brew uninstall --ignore-dependencies icu4c
brew install pkg-config icu4c  # keg-only

PyICU (pypostal dependency)

pip uninstall pyicu

export PATH="/usr/local/opt/icu4c/bin:/usr/local/opt/icu4c/sbin:$PATH"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/icu4c/lib/pkgconfig"

# ensure system clang is used for proper libstdc++
unset CC CXX

pip install --no-binary=:pyicu: pyicu  # avoid wheels from previous runs or PyPI

libpostal (pypostal dependency)

One-liner (using HEAD as v1.1 was released in 2018):

brew install --HEAD robsalasco/libpostal/libpostal

Or manually:

brew install curl autoconf automake libtool pkg-config gcc@8

export CC="/usr/local/bin/gcc-8"
alias gcc="gcc-8"

git clone
cd libpostal
./configure --datadir="${HOME}/.libpostal"
make -j4
sudo make install


pip install postal

# test installation by parsing an example address
python -c "from postal.parser import parse_address; my_address = '123 Beech Lake Ct. Roswell, GA 30076'; print({v: k for k, v in dict(parse_address(my_address)).items()})"
# {'house_number': '123', 'road': 'beech lake ct.', 'city': 'roswell', 'state': 'ga', 'postcode': '30076'}
Copy link

andilabs commented Oct 18, 2019

hello from OS X 10.5 followed all the steps and still on import icu gettings this:

Python 3.7.4 (default, Jul  9 2019, 18:13:23)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import icu
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/andi/pyicu/icu/", line 37, in <module>
    from _icu import *
ImportError: dlopen(/usr/local/lib/python3.7/site-packages/, 2): Symbol not found: __ZN6icu_648ByteSink15GetAppendBufferEiiPciPi
  Referenced from: /usr/local/lib/python3.7/site-packages/
  Expected in: flat namespace
 in /usr/local/lib/python3.7/site-packages/

Copy link

ddelange commented Oct 19, 2019

Hey @andilabs
I have seen this error before during initial installation, and I'm not 100% sure what causes/solves this issue on MacOS. But after repeated trial & error I managed to get it to work by starting from scratch and I haven't touched the installation since.

There is probably some conflict with the system-installed ICU or some issue with (possibly multiple) icu-config alias(es) on your system (see this comment by the PyICU dev: ovalhub/pyicu#112 (comment)).

Please let me know if you solve this issue, and what solved it. We can adapt the instructions to help others with this strange issue.

For what it's worth, I'm using gcc@8 as system wide default C++ compiler as opposed to the default clang.

Copy link

iyabchen commented Dec 19, 2019

Just for a reference, tried the method you mentioned and it won't work for me no matter how many times I start from scratch.
And at last I do pyenv uninstall the whole virtualenv, create a new one, and do the following, and it works! (does not even require to reinstall icu4c).

CFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib pip install pyicu==2.3.1

Copy link

ddelange commented Jan 9, 2021

Hi @iyabchen, thanks for your reply. I just did a succesfull install of pyicu==2.6.0 on a mint machine, by making sure its (which attempts to use the deprecated icu-config, but falls back to pkg-config) finds brew's keg-only icu pkgconfig. No more manual setting of compiler flags :)

I've updated the gist with this simplification, and also added brew install robsalasco/libpostal/libpostal.

Copy link

jketcham commented Mar 18, 2022

Just ran into this myself and creating a new virtualenv with pyenv did the trick as well, didn't have to reinstall pkg-config or icu4c after having installed with homebrew.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment