OSError: [Errno 13] Permission denied when installing django - python

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.)

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

IOError:[Error 13]: Permission denide: 'c:\\users\\ravikumar.mevada\\anaconda2\\Lib\\site-packages\\win32\\win32api.pyd'

I am using python 2.7, 32 bit on windows 10, 64 bit. Whenever I try to install psychopy module by doing pip install psychopy, I am getting below mentioned error. I am not able to understand what is the problem. I have also made changes in environmental variable to set anconda bin and anaconda scripts as highest priority. I am running same program for last 8 months and never got any kind of problem. I am trying to install everything in new PC and getting this kind of error in my old and new PC. How can fix this problem?
Exception:
Traceback (most recent call last):
File "c:\users\ravikumar.mevada\anaconda2\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "c:\users\ravikumar.mevada\anaconda2\lib\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "c:\users\ravikumar.mevada\anaconda2\lib\site-packages\pip\req\req_set.py", line 784, in install
**kwargs
File "c:\users\ravikumar.mevada\anaconda2\lib\site-packages\pip\req\req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "c:\users\ravikumar.mevada\anaconda2\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "c:\users\ravikumar.mevada\anaconda2\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "c:\users\ravikumar.mevada\anaconda2\lib\site-packages\pip\wheel.py", line 323, in clobber
shutil.copyfile(srcfile, destfile)
File "c:\users\ravikumar.mevada\anaconda2\lib\shutil.py", line 97, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: 'c:\\users\\ravikumar.mevada\\anaconda2\\Lib\\site-packages\\win32\\win32api.pyd'
Looks like your user doesn't have the permission to install packages in your system (for all users). Here's how to fix this problem:
From the Command Prompt, you can install the package for your user only, like this:
pip install <package> --user
OR
You can install the package as Administrator, by following these steps:
Run the Command Prompt as Administrator, using the Run This Program As An Administrator option.
Run the command pip install <package>
open your command prompt by right click -> open as administrator after that
type:
py -2.7 -m pip help
py -2.7 -m pip install psychopy
OR
conda create -n py27 python=2.7 anaconda
https://conda.io/docs/user-guide/tasks/manage-python.html

unable to install package using pip

I am trying to install module using pip and I get this error:
$ pip install virtualenv
Collecting virtualenv
Downloading virtualenv-15.0.3-py2.py3-none-any.whl (3.5MB)
100% |████████████████████████████████| 3.5MB 312kB/s
Installing collected packages: virtualenv
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_set.py", line 742, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/wheel.py", line 346, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/wheel.py", line 324, in clobber
shutil.copyfile(srcfile, destfile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/virtualenv.py'
What is the problem and how can I resolve it?
the problem is caused because you have not given the super user permission to the system. in order to make any changes into the system you should go to super user mode, for that you have to type the code as
sudo pip install virtualenv
it will help you out
It's probably because the user you are logged as can't install to that folder.
First option: You can do:
sudo pip install virtualenv
to download as root user
Second Option: you could do these commands in sequence in terminal:
First:
cd /Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/
This command will go to the folder you have pip installed in.
Second:
ls -l
This command will show permissions for files/folders. In on the of the columns you will see users who has access to folder pip (eg. root).
Third: Change it to the user you are logged in as with instead of root:
sudo chown -R your_username:your_username path/to/pip/
This is assuming that folders up in the hierarchy don't have root permissions, otherwise you would need to change them too. I'm talking about: Library, Python etc.

I can't upgrade pip on my raspberry pi

I want to install simpleaudio but can't upgrade or install anything with pip, here's what it gives me:
Downloading/unpacking pip from https://pypi.python.org/packages/9c/32/004ce0852e0a127f07f358b715015763273799b d798956fa930814b60f39/pip-8.1.2-py2.py3-none-any.whl#md5=0570520434c5b600d89ec95393b2650b
Downloading pip-8.1.2-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded
Installing collected packages: pip
Found existing installation: pip 1.5.6
Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS
Can't roll back pip; was not uninstalled
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 295, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1436, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 672, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 902, in move_wheel_files
pycompile=self.pycompile,
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 214, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 204, 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/pip-8.1.2.dist-info'
Storing debug log for failure in /home/pi/.pip/pip.log
I'm using Rasbian with NOOBS if that help figuring this out. I've just started studying programming so I have no clue what I need to do since using the guides results to above, so please explain this to an idiot.
pip fails to access some system paths and shows clearly that the user used to run pip does not have enough privileges to access them.
To solve this, try to run these commands as root using sudo:
sudo pip <options>
Otherwise, if you don't have sudo installed (this is almost impossible) or if you're just curious and know the root's password, simply log in as root and execute your commands without sudo:
su # or su root
# type the root's password
pip <options>
If you use this option, don't forget to log out after you've installed everything!

Install module 'requests' on python 3.5.1 mac [duplicate]

This question already has an answer here:
Installing pip on Mac OS error - Permission denied: '/Library/Python/2.7/site-packages/pip'
(1 answer)
Closed 6 years ago.
I am very new to python and have recently installed python 3.5.1 and am trying to install the module 'requests' by writing the following in terminal:
pip install requests
However I am receiving the following error. Thank you so much in advance for any help that you can give!
Collecting requests
Using cached requests-2.9.1-py2.py3-none-any.whl
Installing collected packages: requests
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/req/req_set.py", line 732, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/req/req_install.py", line 835, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip-8.1.0- py2.7.egg/pip/req/req_install.py", line 1030, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/wheel.py", line 344, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/wheel.py", line 315, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-8.1.0- py2.7.egg/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/requests'
You're attempting to install requests to a place you do not have permissions to do so.
If you sudo it, ie. sudo pip install requests it will succeed. Else you can look into virtual environments to manage dependancies locally.
Also, you're installing the Python 2.7.x version of requests, due to using the Python 2.7.x version of pip. You'll need to use the pip for 3.5 explicitly if that's the one you want to install. There will either be a pip3.5 binary, or you can launch it with the full path to pip for Python 3.5.x

Virtualenv venv fails with the following error

I'm new to Python development and I'm trying to instal virtualenv in my project directory.
However I have the following error:
Installing collected packages: pip, setuptools
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/basecommand.py", line 232, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/commands/install.py", line 347, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/req/req_set.py", line 549, in install
**kwargs
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/req/req_install.py", line 754, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/req/req_install.py", line 963, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/wheel.py", line 234, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/wheel.py", line 212, in clobber
shutil.copyfile(srcfile, destfile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 82, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip/__init__.py'
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/Library/Python/2.7/site-packages/virtualenv.py", line 825, in main
symlink=options.symlink)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 993, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 961, in install_wheel
'PIP_NO_INDEX': '1'
File "/Library/Python/2.7/site-packages/virtualenv.py", line 903, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/alexandrurada...oard/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 2
I installed pip with
easy_install pip
Then I installed virtualenv with
pip install virtualenv
Without any errors. However I'm still getting this. I didn't want to try it with sudo. Should I?
UPDATE: I installed them with sudo, and I got rid of this error. However another one when trying to install something with pip:
air:dashboard alexandrurada$ pip install flask
-bash: /usr/local/bin/pip: "path_here": bad interpreter: No such file or directory
UPDATE 2: The earlier error was because of a space inside a directory name. Looks like path doesn't work with such names.
Anyway, the error I'm getting now is
File "/usr/local/bin/pip", line 7, in <module>
from pip import main
ImportError: No module named pip
I checked my /usr/local/bin/pip and the file exists.
You need sudo pip install virtualenv to install virtualenv globally. When setting up your virtualenvs make sure you don't use sudo and that you activate your virtualenv before trying to install.
[Errno 13] Permission denied: means you don't have write permissions.
Install a newer version of pip and avoid using easy_install.
Download pip from: https://bootstrap.pypa.io/get-pip.py
and then run Python on it:
$ python get-pip.py
If you want to install pip to the global path, you likely want to run that last command with sudo. Without using sudo, pip will get installed for use with whatever Python interpreter is in your path.
From here, you can install virtualenv with pip:
$ pip install virtualenv
From your responses, it seems like you'd be best served by getting your system in a known state: Download that file, then run sudo python get-pip.py so you're running with a known-working pip install.

Categories