betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

26 November 2011

Installing psycopg2 on Mac OS X 10.6 with a 64bit Python

Balance Postgres, Python, and bits

While installing a Django application that uses Postgres on my MacBook with Mac OS X 10.6 (Snow Leopard), I ran into some problems that were all over the net. The symptom was that when I tried to pip install the app's requirements, I got a traceback with something like this for psycopg2:

dlopen([...]/psycopg2/, 2): Symbol not found: _PQbackendPID
Expected in: flat namespace

Searching the web for this found lots of things, but they didn't seem to work for me... because of some dead bodies in my Mac's basement. Basically this errors happens due to a mismatch of 32 or 64 bitness of Python, psycopg2, and Postgres. I had installed Postgres from the official installer (9.1.1), Python 2.7 was standard from the system (which is 64bit). First attempt to fix the mess, following a tipp from Anna Vester, I tried to recompile psycopg2:

pip uninstall psycopg2
env ARCHFLAGS="-arch x86_64" pip install psycopg2

I'm not using sudo, because I'm in a virtualenv and also I didn't dual install for i386 as suggested in the blog post. There were a lot of posts out there telling me simply to reinstall psycopg2, which didn't get me anywhere.

But... even with this it didn't work for me. I found some other hints out there that got me looking in the right direction. The second problem was that I had an old version of Postgres around, from when my MacBook was running 10.4. The pg_config from that old version didn't like the psycopg2, even in 64bit. Pointing my path to the new postgres bin directory instead of the old one solved that too.

Posted by betabug at 19:33 | Comments (2) | Trackbacks (0)
ch athens
Life in Athens (Greece) for a foreigner from the other side of the mountains. And with an interest in digital life and the feeling of change in a big city. Multilingual English - German - Greek.
Main blog page
Recent Entries
Best of
Some of the most sought after posts, judging from access logs and search engine queries.

Apple & Macintosh:
Security & Privacy:
Misc technical:
Athens for tourists and visitors:
Life in general:
<< Bragging on AppleScript | Main | Hiking Flambouritsa >>
Re: Installing psycopg2 on Mac OS X 10.6 with a 64bit Python

Hey! you finally got it!

Quite strange I never found this bug in my laptop, but I always install psycopg, python and postgresql using macports (which takes care of upgrades too, and so avoiding old files wandering around).

Now, time to work on that app! :P

Posted by: Wu at November 27,2011 20:11
Re: Installing psycopg2 on Mac OS X 10.6 with a 64bit Python

Wu, it's not a bug, it was only some old software lying around. :-)

Posted by: betabug at November 29,2011 14:00
You can trackback to:
There are no trackbacks.
Leave a comment