Filed under: postgres
Today, I’ve been trying to get PsycoPG2 installed on my Macbook so that I can run through some tests and try and improve the user experience on Who’s Playing and hopefully increase it’s usage. I re-installed OSX the other week, and there’s still some little things like this to catch.
First off, I tried installing it via Macports, which worked Ok, but didn’t install it in a directory that the default Apple install of Python could see, it put it in the Macports directory. After a while I couldn’t find any way to change the install dir, so I ran:
python_switch python25
which lost all my other libraries, and the Django framework. Not quite what I wanted really.
python_switch python-apple
Will switch you back to the Apple install.
The easiest thing to do is just to download the latest psycopg2 tarball, and edit the setup.cfg file. I also installed Postgres from the official Mac binary, not from Macports, so I told it to use pg_config from that install. Uncomment the pg_config line and point it to your install of Postgres.
pg_config=/Library/PostgreSQL/8.3/bin/pg_config
Then run setup.py
sudo python setup.py install
Job Done.
Update: For Snow Leopard users, you might also see the following error:
Symbol not found: _PQbackendPID
The solution, that I found on Kreegers blog, is to tell Snow Leopard that python needs to run in 32bit mode:
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
7 Comments so far
Leave a comment


Hi – so sorry for the delay in getting in contact. I was flagged up about your tweet regarding the UK Domino’s website. We did have a slight problem on Friday night – but can you give me some more details please? Can you drop me an email please?
Comment by Georgina Wald September 27, 2009 @ 7:56 amThanks. Georgina – Corporate Communications Manager.
[...] I then followed this to get psycopg2 installed to prep Postgresql for use with DJango http://stubblog.wordpress.com/2009/06/07/installing-psycopg2-on-osx/ [...]
Pingback by Installing Postgresql for Mac for Django « Michael Bushe's Tech Blog January 12, 2010 @ 3:29 pmHoly crap, thank you so much for the Snow Leopard hint. I’ve been trying to solve that problem for days.
Comment by Jim May 28, 2010 @ 4:12 amThanks a lot for this. Setting up psycopg2 on Snow Leopard was turning out to be a huge pain until I found your article.
Comment by James August 4, 2010 @ 3:14 amThanks a lot. It worked perfectly.
Comment by exapted August 25, 2010 @ 12:19 pmvery informative
Comment by Lashay Dewitz October 21, 2010 @ 11:20 amWhen do I have to spec to run Python in 32-bit? Before or after the Python Setup.py Install ???
Im running 8.4.5 on MacOS 10.6.6 and it still shows the Symbol not found: _PQbackendPID
Your help will be appreciated.
Comment by Vlad February 11, 2011 @ 6:44 pm