permission denied pip virtualenv - python

I have been trying to set up virtualenv for use with django, but I keep having issues installing virtualenv with pip.
jeff#jeff-HP-MacBook-Android:~/repos$ pip install virtualenv
Collecting virtualenv
Using cached virtualenv-13.1.2-py2.py3-none-any.whl
Installing collected packages: virtualenv
Exception:
Traceback (most recent call last):
File "/home/jeff/.local/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/home/jeff/.local/lib/python2.7/site-packages/pip/commands/install.py", line 311, in run
root=options.root_path,
File "/home/jeff/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 646, in install
**kwargs
File "/home/jeff/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 803, in install
self.move_wheel_files(self.source_dir, root=root)
File "/home/jeff/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
isolated=self.isolated,
File "/home/jeff/.local/lib/python2.7/site-packages/pip/wheel.py", line 339, in move_wheel_files
clobber(source, lib_dir, True)
File "/home/jeff/.local/lib/python2.7/site-packages/pip/wheel.py", line 317, in clobber
shutil.copyfile(srcfile, destfile)
File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/virtualenv.py'
jeff#jeff-HP-MacBook-Android:~/repos$
The closest answer I can find regards permissions inside the virtualenv: How to avoid "Permission denied" when using pip with virtualenv
But from what I can tell my issue is that there's something wrong with my install of pip, since I apparently don't even have virtualenv yet.

I don't think there's anything wrong with your pip installation. virtualenv is itself a Python module, and by default it goes in /usr/local/lib/python2.7/dist-packages, a folder for which your user does not have write permissions. If you have sudo access, it would be easiest to simply try:
sudo pip install virtualenv
Once you've done that, you should be able to create virtualenvs without needing to use sudo. Alternately, there are instructions here for making your own virtual environment, but it looks like you will likely need to do some manual editing of the script it directs you to download.

Related

Installing python module IOError: [Errno 13] Permission denied:

I tried to install the python library openpyxl using pip by typing into the terminal:
pip install openpyxl
But it was not executed properly. It threw an exception:
Successfully built openpyxl jdcal et-xmlfile
Installing collected packages: jdcal, et-xmlfile, openpyxl
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 323, 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/jdcal.py'
Best way is probably to use pip install <libname> --user
Meaning in your case use pip install openpyxel --user
This installs the package for your user and that is safe. Also you have probably the right of installing the package for the user.
The permission error you have encountered is a frequent problem. As can be seen here:
pip is not able to install packages correctly: Permission denied error
and here error: could not create '/usr/local/lib/python2.7/dist-packages/virtualenv_support': Permission denied
Using the sudo pip command is not considered as safe as explained here: What are the risks of running 'sudo pip'?
Your user doesn't have write permissions in the Python installation folder.
To fix it, run pip as root:
sudo pip install openpyxl
Your account does not have write access to this directory?.
If the installation directory is a system-owned directory, you may
need to sign in as the administrator or "root" account.
sudo pip install openpyxl
If you do not have administrative access to this machine, you may
wish to choose a different installation directory, preferably one
that is listed in your PYTHON_PATH environment variable.
easier way: change that dir permission:
chmod +a 'user:YOUR_USER_NAME allow add_subdirectory,add_file,delete_child,directory_inherit' /Library/Python/2.7/site-packages
Change security setting of site-packages folder to "Full Control" for your user and re run pip install openpyxl

Permission denied error in pip installing pyopenssl

As I'm trying to force reinstall pyopenssl, I'm running into the following error when it tries to install pycparser. I am doing this on Windows 7 64-bit with Python 2.7 using the following command:
pip install pyopenssl --ignore-installed
Here is the traceback:
Exception:
Traceback (most recent call last):
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip-8.1.2-py2.7.egg\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip-8.1.2-py2.7.egg\pip\commands\install.py", line 317, in run
prefix=options.prefix_path,
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip-8.1.2-py2.7.egg\pip\req\req_set.py", line 742, in install
**kwargs
File "C:\Python27\ArcGIS10.4\lib\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 "C:\Python27\ArcGIS10.4\lib\site-packages\pip-8.1.2-py2.7.egg\pip\req\req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip-8.1.2-py2.7.egg\pip\wheel.py", line 346, in move_wheel_files
clobber(source, lib_dir, True)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip-8.1.2-py2.7.egg\pip\wheel.py", line 324, in clobber
shutil.copyfile(srcfile, destfile)
File "C:\Python27\ArcGIS10.4\lib\shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: 'C:\\Python27\\ArcGIS10.4\\Lib\\site-packages\\_cffi_backend.pyd'
Here is what I have noticed:
It only happens with _cffi_backend.pyd - other packages install and
uninstall fine.
I can pip uninstall cffi and re-install it alright, but whenever it
is present, the _cffi_backend.pyd permission error presents. This means that any installations calling cffi (for example pyopenssl) will fail.
Here is what I've tried:
Uninstalling and reinstalling cffi: no effect
Successfully used icalcs to set _cffi_backend.pyd to full access, everyone: no effect
Calling pip with python -m pip install pyopenssl --ignore-installed: no effect
Closed all applications and examined running processes before
installing: no effect
Reboot. Voodoo for the most part, but just to be thorough: no effect

Python: permission denied error when installing pip

I am a student and I am doing project on department computer, system Linux 7.2. Now I am trying to install pip so that I can install python packages using it.
I have downloaded get-pip.py and tried to install via python get-pip.py. It gives me:
Collecting pip
Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
100% |████████████████████████████████| 1.2MB 471kB/s
Collecting wheel
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
100% |████████████████████████████████| 71kB 764kB/s
Installing collected packages: pip, wheel
Exception:
Traceback (most recent call last):
File "/tmp/tmpqybTwL/pip.zip/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/tmp/tmpqybTwL/pip.zip/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/tmp/tmpqybTwL/pip.zip/pip/req/req_set.py", line 732, in install
**kwargs
File "/tmp/tmpqybTwL/pip.zip/pip/req/req_install.py", line 835, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/tmp/tmpqybTwL/pip.zip/pip/req/req_install.py", line 1030, in move_wheel_files
isolated=self.isolated,
File "/tmp/tmpqybTwL/pip.zip/pip/wheel.py", line 344, in move_wheel_files
clobber(source, lib_dir, True)
File "/tmp/tmpqybTwL/pip.zip/pip/wheel.py", line 315, in clobber
ensure_dir(destdir)
File "/tmp/tmpqybTwL/pip.zip/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/lib64/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/pip'
Then, I tried to install using sudo python get-pip.py, however, I got "xxx is not in the sudoers file. This incident will be reported."
So, I was wondering whether I don't have the permission to root and don't have the right to do sudo...but I am not sure about this...
Any suggestion to fix this problem? And in the end, I want to install scipy and gensim.
Does the system hand you a virtualenv command?
Then you should read about virtualenvs. Comes in handy anyhow.
If not you may use the approach by Jasper van den Bosch
You either need to use a virtual environement, and install the pip package in the virtual env. Or install it with pip globally ie system wide as root user
Try install pip using easy_install
Try Below commands in terminal:
sudo su
easy_install pip

pip install django error

I'm trying to install django using pip in Terminal.
I always get an exception, however. The last error is always "permission denied", and I do not understand why. Any help is appreciated.
Log:
pip install django
You are using pip version 7.1.0, however version 8.1.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting django
Using cached Django-1.9.4-py2.py3-none-any.whl
Installing collected packages: django
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/commands/install.py", line 299, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 646, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 813, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 1008, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/wheel.py", line 339, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/wheel.py", line 310, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/utils/__init__.py", line 70, 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/django'
sudo pip install django
The error tells you that you can't access a directory (you don't have enough permissions), so you can gain root access via sudo to get the permissions.
pip should be run by a user which has permissions to write to site-packages directory (in your case, /Library/Python/2.7/site-packages/). You should either run it from the root user or under sudo.
My Solution for [Errno 13] Permission denied:
Target: To install package into system/virtualenv
Why you get this problem?
Because apart from root, other users you created don't have permission to write to site-packages, that is why you get OS error permission denied for that user
How to solve?
Make sure you activated the virtualenv all the time
Source bin/activate
Suppose, I created a user
(sampleEnv) sunny#ubuntu-512mb-lon1-01: pip install django
This will give the Permission error, Instead of that shift to root
$ su -
(sampleEnv) root#ubuntu-512mb-lon1-01: pip install django
Now root have permission to write to site-packages.
Once django is installed. Shift back to user
$ su - sunny
then do pip freeze you can see packages installed in system and go on!

pip install/upgrade error for Python2.7, 3.4

Python Version=2.7, 3.4
So I'm trying to update pip since I get the following message in the terminal.
You are using pip version 7.0.3, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
and this.
Collecting pip
Using cached pip-7.1.2-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 7.0.3
Uninstalling pip-7.0.3:
and then I get an error that says,
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/commands/install.py", line 297, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_set.py", line 616, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_install.py", line 721, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_uninstall.py", line 126, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/utils/__init__.py", line 314, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 300, in move
rmtree(src)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 247, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 252, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 250, in rmtree
os.remove(fullname)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/EGG-INFO/dependency_links.txt'
How do I fix this error?
The installation needs file permissions that you don't have.
run with sudo (sudo pip install...) or as root user. You will need the root password for that.
The unix standard file system hierarchy is such a normal user (even an administrator) don't have write permissions to most places outside their homedir. To change things in the "global" paths of the hierarchy you need to have higher permissions. root is generally the high permissions user. running a command by prefixing it with sudo means running it as another user and usually with root permissions, it can then write to places such /Library where pip is trying to install.
Some more about the standard: https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
Try Deleting pip-7.0.3-py2.7.egg and pip.pth* from /Library/Python/2.7/site-packages/ then try to execute pip install --upgrade pip command in terminal

Categories

Resources