Trouble installing psycopg2 on CentOS

hdx picture hdx · Jan 27, 2011 · Viewed 34.1k times · Source

I'm trying to install psycopg2 on CentOS, I followed everything on this tutorial from "On with it: Installing Python 2.6" all the way to when it imports psycopg2, but when I try to import I get the following error:

 Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/python2.6/lib/python2.6/site-packages/psycopg2/__init__.py", line 69, in <module>
    from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: libpq.so.5: cannot open shared object file: No such file or directory

How to troubleshoot this?

Answer

wkl picture wkl · Jan 27, 2011

psycopg2 is a python wrapper around the PostgreSQL libraries, so you need those installed on your system too.

Since you're using CentOS, try this from the command line to install the postgre libs.

yum install postgresql-libs