我首先通过Homebrew公式安装了icu4c
:
$ brew install icu4c
$ ls /usr/local/Cellar/icu4c/
64.2
然后相应地设置标志:
export ICU_VERSION=64
export PYICU_INCLUDES=/usr/local/Cellar/icu4c/64.2/include
export PYICU_LFLAGS=-L/usr/local/Cellar/icu4c/64.2/lib
,然后从pip
安装PyIcu:
$ pip install pyicu
Successfully installed pyicu-2.3.1
但是在导入时: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
答案 0 :(得分:1)
我在MacOS上也遇到了同样的问题,我使用较旧的pyicu = 1.9.7解决了该问题
$ pip install pyicu=1.9.7