OSError: [Errno 13] Permission denied when installing django
You need to activate your virtual environment first.
$ source PATH_TO_ENV/bin/env
$ pip install django
In a newly created virtualenv there will also be a activate shell script. For Windows systems, activation scripts are provided for the Command Prompt and Powershell.
On Posix systems, this resides in
/ENV/bin/
Unless you do this you are using system python and system libs. That's why you see the error.
If you need to install a lib into the system scope you need root access:
$ sudo pip install django
Related videos on Youtube
Comments
-
import-antigravity over 1 year
I am on ubuntu 14.04 freshly installed, and I have installed pip and virtualenvironment but when I try to install django I get the following error message:
name@computername:/$ pip install django Collecting django Using cached Django-1.7.4-py2.py3-none-any.whl Installing collected packages: django Exception: Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/basecommand.py", line 232, in main status = self.run(options, args) File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/commands/install.py", line 347, in run root=options.root_path, File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/req/req_set.py", line 549, in install **kwargs File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/req/req_install.py", line 740, in install self.move_wheel_files(self.source_dir, root=root) File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/req/req_install.py", line 949, in move_wheel_files isolated=self.isolated, File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/wheel.py", line 234, in move_wheel_files clobber(source, lib_dir, True) File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/wheel.py", line 205, in clobber os.makedirs(destdir) File "/usr/lib/python2.7/os.py", line 157, in makedirs mkdir(name, mode) OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/django'
It does, however work when I try installing on a venv.
Could this have anything to do with $PYTHONPATH?
(I believe this is also causing conflicts when I try to run runserver on an already started project. But I will leave that for another question if this one doesn't resolve it.)
-
import-antigravity about 9 yearsInstalling and running django on a virtual env works fine. It's ony when I try doing it in the system that it doens't work. I wanted to have a copy on on my system aswell as on my venv. Is that unecessary?
-
Pavel Reznikov about 9 yearsTo install a library in system scope you need root access. See UPD.
-
import-antigravity about 9 yearsI don't know how I missed that. thanks for the answer!