Installation of psycopg2 fails within virtualenv folder in Ubuntu 12.04 – how do I fix this?

Recently, when I attempted to install the PostgreSQL adapter for Python ( psycopg2 ), in a virtualenv folder in Ubuntu 12.04, it failed. Upon attempting several solutions, I have boiled down to a fix that worked and decided to document it in an effort to help others resolve similar issue.

# Install the PostgreSQL development files (if you haven't installed them already).
sudo apt-get install postgresql-server-dev-all

# Install other required libraries
sudo apt-get install libpq-dev python-dev

# Attempt installation of psycopg2 within the virtualenv folder.
source /bin/activate
pip install psycopg2

# The installation of psycopg2 should proceed smoothly by now. If it still fails, try installing the postgresql-client libraries.
sudo apt-get install postgresql-client-common

# Attempt installation of psycopg2 again and hopefully it should work without issues.


References:

Advertisements

2 thoughts on “Installation of psycopg2 fails within virtualenv folder in Ubuntu 12.04 – how do I fix this?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s