Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am attempting to install django to a virtualenv that already exists.

Following the instructions listed on the pip-install website here, I ran the following from SSH.

name@server:~$ . myenv.env/bin/activate
(myenv.env)nam@server:~$ pip install django

However at the bottom of the installation, I am seeing this:

creating /usr/local/lib/python2.7/dist-packages/django

error: could not create '/usr/local/lib/python2.7/dist-packages/django': Permission denied

It appears that it is trying to install it to the global directory. I do not have sudo privileges. Am I doing something wrong here?

Update: $PATH = /var/django/myenv.env/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

share|improve this question
Does it work correctly for other packages? Do you have the same problem if you use easy_install? – larsks Jul 26 '13 at 17:28
Same problem with other packages. And I believe easy_install requires sudo and would install into the global directory. – Luke Sapan Jul 26 '13 at 17:53
Nope, setting up a virtualenv gets you easy_install as well as pip. You can type which easy_install to see if you're using your virtualenv or the system one. – larsks Jul 26 '13 at 17:55
Actually, are you sure you're running pip from inside the virtualenv? What does which pip yield? And do you see pip inside myenv.env/bin/? – larsks Jul 26 '13 at 17:56
I do see pip inside of myenv.env/bin/. I just tried "activating" my env again, and despite being in that mode, "which pip" and "which easy_install" both return "usr/local/bin/pip" and "usr/bin/easy_install" respectively. – Luke Sapan Jul 26 '13 at 18:20
up vote 2 down vote accepted

Sorry for a year late answer! I had the same problem and fixed it, I don't know if you changed the name of a directory after creating the virtual environment, I did though. If so then here's what I did.

1.) deactivate your v-env. After the fix you need to restart the v-env, so might as well deactivate now. right?

2.) Now, since we created the v-env in a different path, we have to change the static path variables in these files.

To get pip working you don't need to do this, but I still do. bin/activate, bin/activate.csh, bin/

bin/pip, bin/pip2, bin/pip2.7

bin/easy_install, bin/easy_install2.7

3.) To get pip working, you must correct the python interpreter in the pip file, this as well has a static interpreter location set by virtualenv in the creation process.

4.) To get easy_install working? You guessed it, fix the interpreter location.

I hope this helped for any people reading this in the future. Sorry OP, for being late.

share|improve this answer
Yeah that was exactly it. In my case I was able to just re-create the virtualenv from scratch and that solved it. – Luke Sapan Jun 6 '15 at 16:29
Glad to be of help – Crispy Jun 6 '15 at 16:41

I had this same problem.

I deleted the virtual environment and created a new one, which solved the problem.

Probably not the answer you were hoping for, but since it's the only one...

share|improve this answer

Well without administrative privileges you're very limited on what you are able to do. If you are not allowed to elevate yourself or ask for privileges, the best way I found to go about that would be to create another environment, make a requirements.txt file, download all the packages you need to your machine( django ) that would also be located in your requirements file and it should work.

share|improve this answer

I had the same problem and this worked with me. Try sudo pip install django

share|improve this answer
Sry @LukeSapan I didn't read your question right "I do not have sudo privileges." – Abdullah Dec 3 '13 at 11:45

Had the same problem. In my case the reason was that the created virtual env was for python2.7 (the default) but I was using pip3 to install a package. pip3 was not present in my virtualenv so it defaulted to the global one. For me the fix was to use

virtualenv flask --python=python3

to create the env.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.