views:

753

answers:

4
    Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/Library/Python/2.6/site-packages/psycopg2/__init__.py", line 60, in <module>
   from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/Library/Python/2.6/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID
 Referenced from: /Library/Python/2.6/site-packages/psycopg2/_psycopg.so
 Expected in: flat namespace
 in /Library/Python/2.6/site-packages/psycopg2/_psycopg.so

Psycopg2 was working fine before, but now I get this error.

Any ideas on this issue much appreciated.


EDIT: so after dealing with so many psycopg2 errors everytime I set up my mac, I've decided to use VMWareFusion running Ubuntu instead.

+1  A: 

Could it be that the postgres installation was removed/updated? The symbol is supposed to come from libpq.

Martin v. Löwis
+3  A: 

You get this error because your 64-bit version of python can't find a 64-bit psycopg2.

You can either downgrade your python to run in 32-bit mode or try to get a 64-bit psycopg2. There is more discussion on this topic over on Ben Kreeger's blog.

Don Spaulding
+1  A: 

This is broken for me too, and in my case it doesn't appear to be a 32 vs 64 bit issue:

[email protected][6:55]~/src:85%file /opt/local/lib/postgresql83/libpq.dylib 
/opt/local/lib/postgresql83/libpq.dylib: Mach-O 64-bit dynamically linked shared library x86_64
[email protected][6:56]~/src:86%file ~/.python-eggs/psycopg2-2.0.14-py2.6-macosx-10.6-universal.egg-tmp/psycopg2/_psycopg.so 
/Users/decibel/.python-eggs/psycopg2-2.0.14-py2.6-macosx-10.6-universal.egg-tmp/psycopg2/_psycopg.so: Mach-O universal binary with 3 architectures
/Users/decibel/.python-eggs/psycopg2-2.0.14-py2.6-macosx-10.6-universal.egg-tmp/psycopg2/_psycopg.so (for architecture i386):   Mach-O bundle i386
/Users/decibel/.python-eggs/psycopg2-2.0.14-py2.6-macosx-10.6-universal.egg-tmp/psycopg2/_psycopg.so (for architecture ppc7400):    Mach-O bundle ppc
/Users/decibel/.python-eggs/psycopg2-2.0.14-py2.6-macosx-10.6-universal.egg-tmp/psycopg2/_psycopg.so (for architecture x86_64): Mach-O 64-bit bundle x86_64
[email protected][6:56]~/src:87%
decibel
+1  A: 

resolved similar issue by forcing Apache executables 32 bit execution

Ashok