I'm running Python on a slightly older OS, whose system Python is at version 2.6. Hence I have 2.7 installed in my home directory and used that Python to get pip, and used that pip to install virtualenvwrapper. So I have
$ which python pip virtualenv virtualenvwrapper.sh
/home/user/bin/python
/home/user/bin/pip
/home/user/.local/bin/virtualenv
/home/user/.local/bin/virtualenvwrapper.sh
I use these tools to create a virtualenv, and try to install a module
$ mkvirtualenv fred
New python executable in fred/bin/python2.7.10
Also creating executable in fred/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/preactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/postactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/get_env_details
$ workon fred
$ export PYTHONPATH=/home/user/.virtualenvs/fred/lib/python2.7/site-packages
$ /home/user/.virtualenvs/fred/bin/easy_install --prefix=/home/user/.virtualenvs/fred pip
Creating /home/user/.virtualenvs/fred/lib/python2.7/site-packages/site.py
Searching for pip
Best match: pip 7.1.2
Adding pip 7.1.2 to easy-install.pth file
Installing pip script to /home/user/.virtualenvs/fred/bin
Installing pip3.4 script to /home/user/.virtualenvs/fred/bin
Installing pip3 script to /home/user/.virtualenvs/fred/bin
Using /home/user/.virtualenvs/fred/lib/python2.7/site-packages
Processing dependencies for pip
Finished processing dependencies for pip
$ which python pip
/home/user/.virtualenvs/fred/bin/python
/home/user/.virtualenvs/fred/bin/pip
$ pip install itsdangerous
Collecting itsdangerous
Installing collected packages: itsdangerous
Exception:
Traceback (most recent call last):
File "/home/user/.local/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/home/user/.local/lib/python2.7/site-packages/pip/commands/install.py", line 311, in run
root=options.root_path,
File "/home/user/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 646, in install
**kwargs
File "/home/user/.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/user/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
isolated=self.isolated,
File "/home/user/.local/lib/python2.7/site-packages/pip/wheel.py", line 341, in move_wheel_files
clobber(source, lib_dir, True)
File "/home/user/.local/lib/python2.7/site-packages/pip/wheel.py", line 319, in clobber
shutil.copyfile(srcfile, destfile)
File "/usr/lib64/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/itsdangerous.py'
Why is pip trying to install the module into /usr/lib? Shouldn't it be installed to ~/.virtualenvs/fred/lib, or ~/lib?
Status as of Jul 4th, 2018:
Unreproducible, as I do not have access to that company's servers any more, and I have not seen it on other systems since.
Probably your are calling the system level pip and not the virtualenv pip.
You should activate your virtualenv before:
. bin/activate
Related
What is the problem? I tried "python -m pip install -U pip" and "python -m pip install --upgrade pip" both with the same error (and "pip install -U --force-reinstall pip"). what should I do?
C:\Users\Peyman\PycharmProjects\untitled3>python -m pip install -U pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\req\req_set.py", line 784, in install
**kwargs
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\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\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\wheel.py", line 462, in move_wheel_files
generated.extend(maker.make(spec))
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\_vendor\distlib\scripts.py", line 372, in make
self._make_script(entry, filenames, options=options)
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\_vendor\distlib\scripts.py", line 276, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\_vendor\distlib\scripts.py", line 212, in _write_script
launcher = self._get_launcher('t')
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\_vendor\distlib\scripts.py", line 351, in _get_launcher
result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'
You are using pip version 9.0.3, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Try using easy_install -U pip, according to this bug report.
Edit: Okay, go to "https://pypi.org/simple/pip/", and download the latest .whl file (scroll to the bottom). When you have it, open cmd in the same folder (by clicking File -> open powershell/cmd in the file explorer), and type
pip install filename, with filename being the name of the file you downloaded (Should be pip-18.0-py2.py3-none-any.whl).
Try that and tell me if it works.
You can try this following:
python -m pip install -U --force-reinstall pip
My answer is a variation of assmmahmud's but for me I had to use the option --user.
I'm on windows so from CMD.exe;
py -m pip install --user --force-reinstall -U
If I don't use the --user option then the error occurs.
Download get-pip.py from the official site and run this code:
$ python get-pip.py
or on Windows, this one:
py get-pip.py
I have built a simple PyGTK app using Python 3.5.2 and Msys but I need some modules not in the default installation, and although I could use setup.py install to get them I would much rather use pip.
I looked around and found this but it relates to Python 2 and gave an error when attempting to follow the instructions given:
$ python3 getpip.py
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
Collecting setuptools
Using cached setuptools-38.2.5-py2.py3-none-any.whl
Collecting wheel
Using cached wheel-0.30.0-py2.py3-none-any.whl
Installing collected packages: pip, setuptools, wheel
Exception:
Traceback (most recent call last):
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\req\req_set.py", line 784, in install
**kwargs
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\req\req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\req\req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\wheel.py", line 462, in move_wheel_files
generated.extend(maker.make(spec))
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\_vendor\distlib\scripts.py", line 372, in make
self._make_script(entry, filenames, options=options)
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\_vendor\distlib\scripts.py", line 276, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\_vendor\distlib\scripts.py", line 212, in _write_script
launcher = self._get_launcher('t')
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\_vendor\distlib\scripts.py", line 351, in _get_launcher
result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'
and I tried the way one would install pip on Linux:
pacman -S python2-pip
pacman -S python-pip
as listed here, as well as:
pacman -S python3-pip
but each time I got a error: target not found: error.
Surprisingly I couldn't find anything else.
So how do I get pip on Msys?
Thanks.
Please note that at this time the following command is now working on msys2:
$ pacman -S python3-pip
$ pip3 install --upgrade pip
The accepted answer installs a new Python exectuable with pip, but without GTK support.
In order to install pip support to the existing GTK Python executable, after encountering that error, we need to run:
python -m pip install -U --force-reinstall pip
(taken from this issue)
To summarize the steps required to install Pip support to the GTK-Python executable:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
(ignore the error from previous step)
python -m pip install -U --force-reinstall pip
To install pip, securely download get-pip.py.
Then run the following:
python get-pip.py
For more details refer: https://pip.pypa.io/en/stable/installing/
This question already has answers here:
pip install failing with: OSError: [Errno 13] Permission denied on directory
(9 answers)
Closed 3 years ago.
I am trying to install the zipline module using "pip install zipline" but I get this exception:
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/editor.pyc'` - any help would be greatly appreciated
Failed building wheel for numexpr
Running setup.py clean for numexpr
Failed to build numexpr
Installing collected packages: python-editor, Mako, sqlalchemy, alembic, sortedcontainers, intervaltree, python-dateutil, numpy, numexpr, toolz, bottleneck, scipy, pytz, pandas, empyrical, requests, requests-file, requests-ftp, pandas-datareader, decorator, networkx, patsy, statsmodels, click, Logbook, multipledispatch, bcolz, Cython, contextlib2, cyordereddict, cachetools, zipline
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 323, 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/editor.pyc'
AS you are not root. You can use sudo to obtain superuser permissions:
sudo pip install zipline
Or else
For GNU/Linux :
On Debian-derived Linux distributions, you can acquire all the necessary binary dependencies from apt by running:
$ sudo apt-get install libatlas-base-dev python-dev gfortran pkg-config libfreetype6-dev
On recent RHEL-derived derived Linux distributions (e.g. Fedora), the following should be sufficient to acquire the necessary additional dependencies:
$ sudo dnf install atlas-devel gcc-c++ gcc-gfortran libgfortran python-devel redhat-rep-config
On Arch Linux, you can acquire the additional dependencies via pacman:
$ pacman -S lapack gcc gcc-fortran pkg-config
There are also AUR packages available for installing Python 3.4 (Arch’s default python is now 3.5, but Zipline only currently supports 3.4), and ta-lib, an optional Zipline dependency. Python 2 is also installable via:
$ pacman -S python2
Avoid using sudo to install packages with pip. Use the --user option instead or, even better, use virtual environments.
See this SO answer. I think this question is a duplicate of that one.
Okay, so, I run my project packages in a virtual environment. I usually manage these packages through PyCharm. PyCharm tells me I have Pip 9.0.1 installed. Only when I run my virtual environment from the command line and I print pip version, it says 7.1.0. If I try upgrading using pip install --upgrade pip I get an error
Collecting pip
Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 7.1.0
Uninstalling pip-7.1.0:
Successfully uninstalled pip-7.1.0
Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\basecommand.py", line 223, in main
status = self.run(options, args)
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\commands\install.py", line 299, in run
root=options.root_path,
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\req\req_set.py", line 646, in install
**kwargs
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\req\req_install.py", line 813, in install
self.move_wheel_files(self.source_dir, root=root)
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\req\req_install.py", line 1008, in move_wheel_files
isolated=self.isolated,
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\wheel.py", line 449, in move_wheel_files
generated.extend(maker.make(spec))
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\_vendor\distlib\scripts.py", line 323, in make
self._make_script(entry, filenames, options=options)
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\_vendor\distlib\scripts.py", line 227, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\_vendor\distlib\scripts.py", line 163, in _write_script
launcher = self._get_launcher('t')
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\_vendor\distlib\scripts.py", line 302, in _get_launcher
result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'
My system-wide pip version is 9.0.1 though. I just don't get what is happening. Hopefully someone can shed some light. I've tried de-installing and re-installing it again, I've tried using a wheel to install, doesn't work
Windows, by the way.
I had the same issue, but found the answer here:
https://github.com/pypa/pip/issues/2669
Basicly I just had to use this command instead:
easy_install -U pip
Open the Command Prompt (cmd) as administrator and run:
pip install --user --upgrade pip
Or try:
python -m pip install --user --upgrade pip
Relevant GitHub issue.
The --prefix option to setup.py (and pip via --install-option) seems broken.
I need to maintain a shared repository of updated python packages on a machine where I do not have sudo access. Theoretically the --prefix option to setup.py (and pip the via --install-option) can do what I need.
However if there is already a version of the package I am installing in the system directories, I cannot install it on my private repository. Installing without --upgrade fails because a package already exists in the system, and installing with --upgrade fails because the old package version cannot be removed. This is shown in the error message below.
Is there any way to prevent install from trying to remove the old version of a package? OR, more likely, am I just not understanding how this is supposed to work?
$ pip --version
pip 1.5.6 from /python-local/lib/python2.7/site-packages (python 2.7)
$ pip install -U --install-option="--prefix=/python-local" virtualenv
Downloading/unpacking virtualenv from https://pypi.python.org/packages/py2.py3/v/virtualenv/virtualenv-1.11.6-py2.py3-none-any.whl#md5=c2aa2fc4986967815f8cb3a3418e6031
Downloading virtualenv-1.11.6-py2.py3-none-any.whl (1.6MB): 1.6MB downloaded
Installing collected packages: virtualenv
Found existing installation: virtualenv 1.7.1.2
Uninstalling virtualenv:
Cleaning up...
Exception:
Traceback (most recent call last):
File "/python-local/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/python-local/lib/python2.7/site-packages/pip/commands/install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/python-local/lib/python2.7/site-packages/pip/req.py", line 1431, in install
requirement.uninstall(auto_confirm=True)
File "/python-local/lib/python2.7/site-packages/pip/req.py", line 598, in uninstall
paths_to_remove.remove(auto_confirm)
File "/python-local/lib/python2.7/site-packages/pip/req.py", line 1836, in remove
renames(path, new_path)
File "/python-local/lib/python2.7/site-packages/pip/util.py", line 295, in renames
shutil.move(old, new)
File "/usr/lib/python2.7/shutil.py", line 300, in move
os.unlink(src)
OSError: [Errno 13] Permission denied: '/usr/bin/virtualenv'
Storing debug log for failure in /home/user/.pip/pip.log
The answer is to use pip's --ignore-installed option. You must use this option whenever a read-only version of the package you are installing is visible in the current environment. This includes when using --user, --local, or --prefix, and also if you are installing into a virtualenv that was created with --system-site-packages
You can find this option mentioned at the very end of this section http://pip.readthedocs.org/en/latest/user_guide.html#user-installs
or with pip install --help