Can't import obj in Python on OS X 10.6.3 Snow Leopard - libiconv.2.dylib?
on 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 ve开发者_运维知识库rsion 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0 >>>
-- what do I need to do?
First I'd try to temporary move /Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/
to somewhere else and try the import statement again. This will enable the OS to import the version of objc
that came with the OS by default (this is in /System/Library
). By using the version in /System/Library
, it works for me:
>>> import objc
>>> print objc.__file__
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC/objc/__init__.pyc
You might also consider moving /opt/local/lib/libiconv.2.dylib
to somewhere else. It looks outdated and OS X Snow Leopard has its own copy of libiconv.2.dylib
in /usr/lib
IIRC.
You more than likely screwed with the OS's Python installation, so you'll more than likely need to reinstall your OS.
精彩评论