2

I'm trying to install Django with PostgreSQL on a CentOS 5.8 system.

It originally had Python 2.4 and I have added the remi repository to install Python 2.6. This works well, and I appear to have both working; if I type 'python' it's the 2.4 version and if I type python2.6 it's the 2.6 version.

When I try to run python2.6 manage.py runserver, I get the error:

Error: No module named psycopg

From the Python command line:

Python 2.6.8 (unknown, Nov  7 2012, 14:47:34)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named psycopg2

Running

python -c 'import sys; print sys.path'
['', '/usr/lib/python2.6/site-packages', '/var/lib/pgsql/.local/lib/python/site-packages', '/var/lib/pgsql/.local/lib/python', '/usr/local/browsershots-read-only/shotserver/shotserver04', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages/Numeric', '/usr/lib/python2.4/site-packages/gtk-2.0']

it looks like I have a confused system with 2.4 and 2.6 interconnected.

If I locate psycopg, I get a shared object in the 2.4 site-packages:

/usr/lib/python2.4/site-packages/psycopgmodule.so

and only source in the 2.6.

What am I doing wrong?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user1548054
  • 21
  • 1
  • 5

1 Answers1

0

IMO you should have a look at virtualenv. This would help you create an isolated environment where you can install your own packages.

Procedure would be:

  • install virtualenv
  • initialise the environment (e.g. using the source ... command)
  • create a new environment (using default options will create a clean one AFAIK)
  • install the psycopg using pip

HTH

Laur Ivan
  • 4,117
  • 3
  • 38
  • 62
  • I'll give this a crack but it sounds like a long winded process, other people must have come across this? Yum needs python 2.4 and everything else appears to need a newer version! – user1548054 Jan 08 '13 at 09:14
  • 1
    @user1548054 you will need to use virtualenv, its not as long winded as you might originally think. It will also help massivly in the future when you need different versions of packages for different projects. – Matt Seymour Jan 08 '13 at 10:08
  • now I need to install pip before virtualenv and to do that I need easy_install ! :) – user1548054 Jan 08 '13 at 11:26
  • Heh. yes, but once you do, all your pain will go away :) – Laur Ivan Jan 08 '13 at 14:00