0

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?

Community
  • 1
  • 1
tedtoy
  • 168
  • 2
  • 12

1 Answers1

1

Clean up after using sudo:

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

Do not use sudo anymore.

Pavel Anossov
  • 60,842
  • 14
  • 151
  • 124
  • Any idea why I get permissions denied errors if I omit the sudo. As in "pip install django"? – tedtoy Mar 06 '13 at 22:51
  • My guess is that after you used sudo, you created a root-owned `build` folder. – Pavel Anossov Mar 06 '13 at 22:52
  • I deactivated the environmeny, rm -rf'ed the venv folder, and restarted the terminal. But when I try running virtualenv venv --distribute, I get "OSError: [Errno 13] Permission denied: 'venv'" – tedtoy Mar 06 '13 at 22:56
  • Do you have the permissions to create files wherever you are doing it? – Pavel Anossov Mar 06 '13 at 22:59
  • It seems I do not. What would be the proper way to give myself permissions to these folders? Thank you for your responses by the way. – tedtoy Mar 06 '13 at 23:11
  • Isn't that your own home directory? What does `ls -la /home/teddy/heroku/battle/hellodjango` tell you? – Pavel Anossov Mar 06 '13 at 23:13
  • I get: teddy@coolermaster:~/heroku/battle/hellodjango$ ls -la total 24 drwxr-xr-x 2 root root 4096 Mar 6 14:54 . drwxr-xr-x 3 root root 4096 Mar 6 13:48 .. -rw-r--r-- 1 root root 0 Mar 6 13:28 __init__.py -rw-r--r-- 1 root root 5365 Mar 6 13:28 settings.py -rw-r--r-- 1 root root 571 Mar 6 13:28 urls.py -rw-r--r-- 1 root root 1434 Mar 6 13:28 wsgi.py – tedtoy Mar 06 '13 at 23:17
  • And after installing the virtual environment "venv", that is listed as : drwxr-xr-x 6 root root 4096 Mar 6 15:18 venv – tedtoy Mar 06 '13 at 23:18
  • So why is everything owned by root? Claim your home: `sudo chown -R teddy:teddy ~` – Pavel Anossov Mar 06 '13 at 23:19
  • Ahh I think that was it - thank you so much. Now when I run the pip command it is downloading django and not giving me the "requreiment already satisfied" message. Thank you for the help, I am still an ubuntu noob apparently. – tedtoy Mar 06 '13 at 23:27
  • Yes, I see that is the recommended advice from google searching this problem. Thanks again, all is working now! – tedtoy Mar 06 '13 at 23:31