Installing psycopg2 for PostGreSQL as django backend using virtualenv

235 views
Skip to first unread message

Doug S

unread,
Jul 14, 2012, 9:56:54 PM7/14/12
to django...@googlegroups.com
Hello django people,
I'm just installing my PostgreSQL backend for my django projects that I install in isolated virtualenv's
I've followed what seem like easy installation instructions here:
I have installed python-dev,   libpq-dev and also postgresql-server-dev-9.1
I workon my virtualenv and use its pip installation to install psycopg2:
(env) $ sudo pip install psycopg2
It appears to install successfully:
Successfully installed psycopg2
but when I use yolk to list my virtualenv packages or look in my site-packages for my virtualenv or try to import psycopg2 I find that it is not installed in the virtualenv like I thought it would be.
I found I do have a psycopg2 installed in my system wide python installation and I'm not sure if my attempt to install it locally actually installed it globally or if the global installation was there to begin with from some set up installation I did using someone else's code ( that I don't pretend to understand )

Two questions:
1) why didn't it install like I expected?
2) do I want psycopg2 insalled in my local virtualenv's python installation for django? or should it be in my global python installation? 

Doug S

unread,
Jul 14, 2012, 10:05:55 PM7/14/12
to django...@googlegroups.com
OK so I uninstalled the global psycopg2 egg and then reinstalled under my virtualenv
It failed to install in my virtualenv but reinstalled in my global python install
So, hopefully this is how its supposed to work,
but the question is why can't my django installation under my virtualenv import my psycopg2 to use it as a backend?
Do I need to reinstall django in the virtualenv ( or start over on my virtaulenv ) so that it installs with psycopg2 installed? or should django just be able to import it?

Ramiro Morales

unread,
Jul 14, 2012, 10:17:18 PM7/14/12
to django...@googlegroups.com
Maybe it is related to he fact you used sudo when running pip intall?

Why are you doing that? After all, one of the advantages of using
a virtualenv is that you don't need o be a system admin
because you don`t want to/can't touch the globali system-wide
installation.

--
Ramiro Morales

Doug S

unread,
Jul 14, 2012, 10:20:20 PM7/14/12
to django...@googlegroups.com
hmmm, OK I didn't know that. I'll try it . . . but I thought I already tried it and got a permission denied error

Doug S

unread,
Jul 14, 2012, 10:29:53 PM7/14/12
to django...@googlegroups.com
Ramario,
thanks,
that was the problem
it works like I expected now
I'm just getting going with django and virtual env's and really Ubuntu
and my thinking was that using sudo would iron out any permission problems if they came up,
didn't know that it would change the version of python it was using like it did.
Lesson learned,
virtaulenv working.

thanks
Doug


On Saturday, July 14, 2012 9:56:54 PM UTC-4, Doug S wrote:
Reply all
Reply to author
Forward
Message has been deleted
0 new messages