Forums

OSError: [Errno 13] Permission denied: '/usr/local/bin/django-admin.py'

I got the above error while attempting to install django==1.7.1. The error can be reproduced as follows:

python3.4 -m venv test --without-pip
cd test
source bin/activate
pip3 install django==1.7.1

The virtual environment is activated, so it should not be trying to install system-wide. Any ideas?

Hmmm. I think we had some problems with the venv module in Python 3.4. Try using plain virtualenv, or virtualenvwrapper?

Or, it might be that you should be running "pip", not "pip3"?

I tried both pip and pip3, same msg. I read on the forum here somewhere that virtualenv was not supported in python3.4, and to use venv instead.

To close out the question, the following worked:

virtualenv --python=python3 dest_dir
cd dest_dir
source bin/activate
pip3 install django==1.7.1

Cool! Thanks for the followup. For me this works as well:

mkvirtualenv --python=/usr/bin/python3.4 SampleVirtualEnv
pip3.4 install django==1.7.1

Note it works regardless of where your current working directory is. There was one line of background setup to make this so easy- but once you do it, you won't ever need to do it again!

  • add source virtualenvwrapper.sh to your bashrc, so that you can use all the mkvirtualenv etc goodies

Other goodies include the fact that you can workon SampleVirtualEnv to open the virtualenv instead of cd-ing and sourcing bin/activate every single time.

A couple notes:

  • When you mkvirtualenv, the SampleVirtualEnv /bin and /lib stuff will by default be created in ~/.virtualenvs/SampleVirtualEnv, and it will automatically workon SampleVirtualEnv (source bin/activate) for you afterwards.
  • For good practice/easier debugging next time, you want to specify python3.4 instead of python3, and pip3.4 instead of pip, just to make sure there are no mixups. running pip3 SHOULD default to pip3.4 but you never know if you changed some setting somewhere to make it default to pip3.3

Thanks!