python - pyicu 无法在 Mountain Lion 上链接 icu4c

标签 python pip homebrew dyld

我使用 brew install icu4cpip install pyicu 来安装 python ICU 支持,但最后我无法在我的 Mountain Lion 上工作。

$ brew install icu4c
dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/sudo) is setuid or setgid
==> Downloading http://download.icu-project.org/files/icu4c/50.1/icu4c-50_1-src.tgz
Already downloaded: /Library/Caches/Homebrew/icu4c-50.1.tgz
==> ./configure --prefix=/usr/local/Cellar/icu4c/50.1 --disable-samples --disable-tests --enable-static --with-library-bits=64
==> make
==> make install
/usr/local/Cellar/icu4c/50.1: 235 files, 55M, built in 109 seconds

$ pip install pyicu
Downloading/unpacking pyicu
  Downloading PyICU-1.4.tar.gz (209kB): 209kB downloaded
  Running setup.py egg_info for package pyicu

Installing collected packages: pyicu
  Running setup.py install for pyicu
    building '_icu' extension
    /usr/bin/clang -fno-strict-aliasing -Os -w -pipe -march=native -Qunused-arguments -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/Cellar/python/2.7.3/include/python2.7 -c _icu.cpp -o build/temp.macosx-10.4-x86_64-2.7/_icu.o -Wno-write-strings -DPYICU_VER="1.4"

…

    /usr/bin/clang++ -bundle -undefined dynamic_lookup -L/usr/local/Cellar/readline/6.2.2/lib build/temp.macosx-10.4-x86_64-2.7/_icu.o build/temp.macosx-10.4-x86_64-2.7/bases.o build/temp.macosx-10.4-x86_64-2.7/calendar.o build/temp.macosx-10.4-x86_64-2.7/charset.o build/temp.macosx-10.4-x86_64-2.7/collator.o build/temp.macosx-10.4-x86_64-2.7/common.o build/temp.macosx-10.4-x86_64-2.7/dateformat.o build/temp.macosx-10.4-x86_64-2.7/errors.o build/temp.macosx-10.4-x86_64-2.7/format.o build/temp.macosx-10.4-x86_64-2.7/iterators.o build/temp.macosx-10.4-x86_64-2.7/layoutengine.o build/temp.macosx-10.4-x86_64-2.7/locale.o build/temp.macosx-10.4-x86_64-2.7/normalizer.o build/temp.macosx-10.4-x86_64-2.7/numberformat.o build/temp.macosx-10.4-x86_64-2.7/regex.o build/temp.macosx-10.4-x86_64-2.7/search.o build/temp.macosx-10.4-x86_64-2.7/transliterator.o build/temp.macosx-10.4-x86_64-2.7/tzinfo.o build/temp.macosx-10.4-x86_64-2.7/unicodeset.o -licui18n -licuuc -licudata -licule -o build/lib.macosx-10.4-x86_64-2.7/_icu.so -L/usr/local/lib

Successfully installed pyicu
Cleaning up...

这是我的设置 安装了 Xcode 4.5 和 46.DP2 的 Mountain Lion。

$ python
Python 2.7.3 (default, Jun 14 2012, 00:46:15) 
[GCC 4.2.1 Compatible Apple Clang 3.1 (tags/Apple/clang-318.0.61)] 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 "/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/icu.py", line 37, in <module>
    from docs import *
  File "/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/docs.py", line 23, in <module>
    from _icu import *
ImportError: dlopen(/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/_icu.so, 2): Symbol not found: __ZNK6icu_5014LEFontInstance10getSubFontEPKtPiiiR11LEErrorCode
  Referenced from: /usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/_icu.so
  Expected in: dynamic lookup

>>> 

$ otool -L _icu.so
_icu.so:
/usr/local/lib/libicui18n.50.1.dylib (compatibility version 50.0.0, current version 50.1.0)
/usr/local/lib/libicuuc.50.1.dylib (compatibility version 50.0.0, current version 50.1.0)
/usr/local/lib/libicudata.50.1.dylib (compatibility version 50.0.0, current version 50.1.0)
/usr/local/lib/libicule.50.1.dylib (compatibility version 50.0.0, current version 50.1.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1669.0.0)

有人遇到过同样的问题吗?我还能尝试什么?

更多信息 /usr/local/bin/python:Mach-O 64 位可执行文件 x86_64 /usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/_icu.so: Mach-O 64 位包 x86_64

最佳答案

最后我通过将 icu4c 版本降级到 4.8.1.1 使其工作。

$ brew uninstall icu4c

$ pip uninstall pyicu

$ brew versions icu4c
4.8.1.1  git checkout 3f0fb81 /usr/local/Library/Formula/icu4c.rb
50.1     git checkout 03ed757 /usr/local/Library/Formula/icu4c.rb
49.1.2   git checkout c25fd2f /usr/local/Library/Formula/icu4c.rb
4.8.1    git checkout 4ed0519 /usr/local/Library/Formula/icu4c.rb
4.4.1    git checkout c1e5cc2 /usr/local/Library/Formula/icu4c.rb

$ cd `brew --prefix`

$ git checkout 3f0fb81 /usr/local/Library/Formula/icu4c.rb

$ brew install icu4c

$ env LDFLAGS="-L/usr/local/opt/icu4c/lib" CPPFLAGS="-I/usr/local/opt/icu4c/include" pip install pyicu        

$ python
Python 2.7.3 (default, Jun 14 2012, 00:46:15) 
[GCC 4.2.1 Compatible Apple Clang 3.1 (tags/Apple/clang-318.0.61)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import icu
>>> 

成功!

关于python - pyicu 无法在 Mountain Lion 上链接 icu4c,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13656756/

相关文章:

python - Pandas 数据框中的分组依据

python - pip3 : command not found but python3-pip is already installed

ssl - nginx v1.10.2 Passenger 403 Homebrew 升级

c++ - OpenCV 架构 x86_64 的 undefined symbol : error

python - 如何在 Django 中重用可重用的应用程序

python - 在 numpy 数组中计算值发生更改之前的长度以及转换次数的最佳方法(最好是 numpythonic)?

python - 扩展用户模型两次?

python-3.x - 用于设置 virtualenv 和 pip 的 Shell 脚本

python - 为什么 pip 找不到 `pip search` 结果中列出的包?

macos - 如何解决在 mac m1 中运行 gcc 失败退出状态 1?