I’m running Mac OSX. Until today I had Python 2.6 with psycopg2 running just fine, I was using it with Django and Pylons. I’ve just reintalled postgres (I don’t know if this is connected) and suddenly I can’t import psycopg2 into Python without a strange error:
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.6-universal/egg/psycopg2/__init__.py", line 69, in <module>
File "build/bdist.macosx-10.6-universal/egg/psycopg2/_psycopg.py", line 7, in <module>
File "build/bdist.macosx-10.6-universal/egg/psycopg2/_psycopg.py", line 6, in __bootstrap__
ImportError: /usr/lib/libpq.5.dylib: no appropriate 64-bit architecture (see "man python" for running in 32-bit mode)
Trying with Python 2.5 gives a similar error:
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/lib/python2.5/site-packages/psycopg2/__init__.py", line 69, in <module>
from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: /opt/local/lib/postgresql84/libpq.5.dylib
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/psycopg2/_psycopg.so
Reason: no suitable image found. Did find:
/usr/lib/libpq.5.dylib: no matching architecture in universal wrapper
I have no idea what this means, where it’s come from, or what to do about it. Please can anyone help?
Have you just upgraded to Snow Leopard by any chance? The Leopard version of Python is 32-bit, while the 64-bit is in Snow Leopard. It breaks some libraries that use native code that aren’t available in 64-bit mode.