tedtoy
tedtoy

Reputation: 178

django not installed in virtualenv, --no-site-packages flag not correcting the issue

The problem I'm having is similar to pip / virtualenv / django installation issue, but the solution posted in that answer is not working for me.

I have created a virtual environment with --no-site-packages using:

virtualenv venv --distribute --no-site-packages

But when I activate the environment and attempt to install django (sudo pip install django), I get the message:

teddy@coolermaster:~/heroku/battle/hellodjango$ source venv/bin/activate
(venv)teddy@coolermaster:~/heroku/battle/hellodjango$ sudo pip install Django  
Requirement already satisfied (use --upgrade to upgrade): Django in   /usr/local/lib/python2.7/dist-packages 
Cleaning up...

Note that in the above message, pip has found the django installation in my local "dist-packages" folder, not my "site-packages"

And if I try importing django in a python interpreter I get the error: "No module named django."

Should I be using the command "pip install django" instead of "sudo pip install django"? When I try running "pip install django" I am greeted by "OSError: [Errno 13] Permission denied: '/home/teddy/heroku/battle/hellodjango/venv/build'"

Could the problem be permissions related (because I am using sudo)? If so why won't it allow me to pip install without sudo? Or could the issue be that my virtualenv is ignoring site-packages but still using the source in my dist-packages?

Upvotes: 0

Views: 796

Answers (1)

Pavel Anossov
Pavel Anossov

Reputation: 62868

Clean up after using sudo:

sudo rm -rf /home/teddy/heroku/battle/hellodjango/venv/build

Do not use sudo anymore.

Upvotes: 1

Related Questions