Thursday, November 12, 2009

psycopg2 on Snow Leopard

I use PostgreSQL with Django, and recently upgraded my MacBook Pro to Snow Leopard (OS X 10.6). Everything went smoothly, except trying to actually run Django. As it turns out, the problem was with using psycopg2 with Python 2.6 on Snow Leopard, because Python is 64-bit by default, and is unable to load the 32-bit psycopg2 module. The error thrown is:

Symbol not found: _PQbackendPID

The solution I found was to re-install Python 2.6, after configuring it to compile in 32-bit.

While doing the standard steps (./configure, make, make install), replace ./configure with:

time ./configure --with-universal-archs=32-bit --enable-universalsdk=/Developer/SDKs/MacOSX10.6.sdk

Note: This put the newly-compiled Python in a location not on the PATH:
/usr/local/bin/python2.6

However, I was able to use that Python version to create my new virtualenv, and everything worked smoothly from there on. I hope this helps somebody, because in my Google searching I found a lot of people with the same problem, but none of the solutions given in any detail worked for me.

No comments:

Post a Comment