Permission Denied Error with virtualenv installing django

March 7, 2014 10.3k views
Following the tutorial: How To Install and Configure Django with Postgres, Nginx, and Gunicorn Step three: Activated the virtualenv then 'pip install django' yielded the error below. Virtualenvs are supposed to alleviate permissions issues. kurt@bangzoom:~$ source /opt/myenv/bin/activate (myenv)kurt@bangzoom:~$ pip install django Downloading/unpacking django Cleaning up... Exception: Traceback (most recent call last): File "/opt/myenv/local/lib/python2.7/site-packages/pip/", line 134, in main status =, args) File "/opt/myenv/local/lib/python2.7/site-packages/pip/commands/", line 236, in run requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) File "/opt/myenv/local/lib/python2.7/site-packages/pip/", line 1058, in prepare_files location = req_to_install.build_location(self.build_dir, not self.is_download) File "/opt/myenv/local/lib/python2.7/site-packages/pip/", line 175, in build_location _make_build_dir(build_dir) File "/opt/myenv/local/lib/python2.7/site-packages/pip/", line 1390, in _make_build_dir os.makedirs(build_dir) File "/opt/myenv/lib/python2.7/", line 157, in makedirs mkdir(name, mode) OSError: [Errno 13] Permission denied: '/opt/myenv/build'
2 Answers
Found answer in tutorial's comments.

sudo chown -R youruser:youruser /opt/myenv

Yeah, you're having to use sudo because that's using the system-wide Python (which, note, is 2.7, not 3.x).

Running pip install django shouldn't create or anything, it just installs Django into site-packages. Can you do startproject foo after you pip install django?

Have another answer? Share your knowledge.