Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a CentOS 5.5 box, which comes preloaded with Python 2.4. I wanted 2.6, so used yumto get it from the EPEL repository. I also used yum to install the psycopg2 package, but it installed it for Python 2.4.

I tried copying /usr/lib/python2.4/site-packages/psycopg2/ to /usr/lib/python2.6/site-packages/, and when I ran my script, it worked... but it gave me a warning that said

/usr/lib/python2.6/site-packages/psycopg2/ RuntimeWarning: Python C API version mismatch for module _psycopg: This Python has API version 1013, module _psycopg has version 1012.

So it looks like there's some kind of versioning issue going on here, and I'm wondering what the best way to fix it is. Should I just ignore the warning and carry on? Is there a way to use yum to install psycopg2 for Python 2.6? Should I just install from source using python26 install? I know installing from source is generally a no-no in CentOS, so I want this to be a last resort, unless it's the only option. I just don't want to mess up yum.

share|improve this question
up vote 1 down vote accepted

I tried copying /usr/lib/python2.4/site-packages/psycopg2/ to /usr/lib/python2.6/site-packages/...

That is not supposed to work.

If you want psycopg2 available to multiple python interpreters, you have a few options... I like virtualenv for juggling multiple python installations on a system. This way you can have as many combinations of sandboxed module versions as you like.

If you just want to install psycopg2 where the Python2.6 libraries are, then we need to clarify python interpreters... let's assume Python2.6 is installed in /usr/bin/python26. I will assume you've satisfied the dependencies for psycopg2 in your Python2.6 install... at this point, download the psycopg2 tarball, untar, cd into the extracted archive directory, and (as root) run /usr/bin/python26 install. This will install psycopg2 for Python2.6.

share|improve this answer
yum deplist psycopg2 returned nothing, so I'm assuming it doesn't have any dependencies? In that case, I think I'll go with this option. I'll mark it as the answer once I get to it. – MattSayar Jul 26 '12 at 21:36
You need the python2.6 development libraries and pg_config, which is an auxiliary binary for PostgreSQL – Mike Pennington Jul 26 '12 at 21:39
OK I have python26-devel and python26-libs installed through yum, but yum can't find libpq-dev. The closest thing I can find is libpqxx-devel in the rpmforge repo. Is there something I'm missing? – MattSayar Jul 26 '12 at 22:10
Update: pg_config was in postgresql-devel in the CentOS Updates repo. – MattSayar Jul 26 '12 at 22:23
Another update: Make sure you have gcc installed as well for the pyscopg2 script. Don't know how I got this far for so long without it. – MattSayar Jul 27 '12 at 14:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.