OS X 10.6.3无法在Python中导入obj Snow Leopard - libiconv.2.dylib?

时间:2010-04-12 17:43:31

标签: python osx-snow-leopard pyobjc

OS X 10.6.3 Snow Leopard上的

% python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import objc
Traceback (most recent call last):
  File "", line 1, in 
  File "/Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/objc/__init__.py", line 22, in 
    _update()
  File "/Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/objc/__init__.py", line 19, in _update
    import _objc
ImportError: dlopen(/Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/objc/_objc.so, 2): Library not loaded: /opt/local/lib/libiconv.2.dylib
  Referenced from: /Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/objc/_objc.so
  Reason: Incompatible library version: _objc.so requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0
>>> 

- 我需要做什么?

2 个答案:

答案 0 :(得分:2)

首先,我尝试将/Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/临时移动到其他地方并再次尝试导入语句。这将使操作系统能够默认导入操作系统附带的objc版本(这在/System/Library中)。通过使用/System/Library中的版本,它适用于我:

>>> import objc
>>> print objc.__file__ 
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC/objc/__init__.pyc

您也可以考虑将/opt/local/lib/libiconv.2.dylib移至其他地方。它看起来已经过时,OS X Snow Leopard在libiconv.2.dylib IIRC中拥有自己的/usr/lib副本。

答案 1 :(得分:-3)

你很可能不熟悉操作系统的Python安装,所以你很可能需要重新安装你的操作系统。