jonypawks

A Boy and His Blog

I have recently been doing some python development that uses the psycopg2 driver for PostgreSQL. On Linux, this worked wonderfully, and everything was installed using the regular easy_install method with no troubles. However on OS X it wasn’t quite so easy.

First I tried using easy_install but it failed with a long list of gcc warnings and errors. Looking near the beginning of the errors I saw:Warning: /bin/sh: pg_config: command not found followed by./psycopg/connection.h:27:22: error: libpq-fe.h: No such file or directory Well this makes sense as I’m using PostgreSQL Plus for OS X, and it doesn’t put it’s header files or libraries in a standard place. There is an easy workaround though.

Original Method

This is left here for historical purposes. I recommend using the above command instead.
We’ll need to download the psycopg2 package and install it manually. Don’t worry, this is very easy and doesn’t require much work at all.

Thanks for this post. I have been doing a lot of searching on how to get psycopg2 installed with the system python on Leopard and haven’t found much of anything that was relevant or recent. I decided to do some more digging at the end of the day and your post popped up.

Thanks for the article. It helped tremendously. Additionally, instead of explicitly specifying the `include_dirs` and `library_dirs` you can uncomment the `pg_config` line and set it to the location of the `pg_config` binary. In my case it is:

Thanks, for this tip. I had exactly the same problem. I switched my dev machine to Mac (because it has better specs) but I still find it hard to adapt to the missing out-of-the-box package management system that I learned to love on debian/Ubuntu.

Putting /Library/PostgresPlus/8.3/bin in your path when running easy_install should also allow the package to find pg_config. I was able to get it to install without editing the package after doing this.

I should clarify, I was using Fink to install pyscopg2 into python2.4 on Snow Leopard, where fink doesn’t have pyscopg2 available for python2.4. If i were using python 2.5 or 2.6, a simple “fink install psycopg2″ would have been sufficient.

Installing psycopg2 on Mac OS X
Friday, 30. October 2009 Filed in: Apple
psycopg2 is an adapter to PostgreSQL for Python. Install this software on GNU/Linux is easy because many distros offer binary packages ready to install it. On Mac OS X is different so we explain how to do that.

Of course, you need to install PostgreSQL and Python before to install this adapter. When you are ready you must follow this steps:

It was determined the killers fleeced about $95,000 from their victims’
welfare advantages — icing on the cake” as Bunting had described it.
The proof provided at trial has driven me to the conclusion that both of you are incapable of
correct rehabilitation,” Justice Martin told
them.