pip install/upgrade error for Python2.7, 3.4 - python

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

Related

Mac: OSError: [Errno 1] Operation not permitted: '/tmp/pip-XcfgD6

When I played with tensorflow in Mac OS, I got this error:
Installing collected packages: html5lib, bleach, markdown, backports.weakref, numpy, funcsigs, pbr, mock, protobuf, tensorflow
Found existing installation: numpy 1.8.0rc1
DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling numpy-1.8.0rc1:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/var/folders/nl/69lb138j255bkbzzjdx1hb6h0000gp/T/pip-1Jo9RF-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'
What does it mean and how do I fix it?
Add the argument --ignore-installed to the pip command you're running. See this question for more.
After some google, I got this was caused by mac OS's SIP machine.
So, I reran pip again with the follow command:
pip install tensorflow --user -U
I finally successfully installed tensorflow.
pip install tensorflow --user -U
It makes sure that you install the library for just your user if you don't have the admin privileges.

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

Reinstalling numpy on OS X using pip - "can’t be modified or deleted because it’s required by OS X"

I'm trying to upgrade the numpy library on macOS, but pip doesn't seem to have sufficient permissions to delete numpy. Running `pip install --upgrade pip gives me this traceback:
➜ Desktop sudo -H pip install --upgrade numpy
Collecting numpy
Using cached numpy-1.11.3-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Installing collected packages: numpy
Found existing installation: numpy 1.8.0rc1
DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling numpy-1.8.0rc1:
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 778, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-21oX9d-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'
So apparently pip is having trouble deleting /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info. Trying to delete this file manually in finder gives me this error:
“numpy-1.8.0rc1-py2.7.egg-info” can’t be modified or deleted because it’s required by OS X.
How can I solve this? (Using the builtin numpy isn't an option because tensorflow, a package I need, needs the newest version).
Was facing the same issue
sudo pip install --ignore-installed numpy
For me on macOS High Sierra the below worked well:
sudo pip install --ignore-installed numpy

permission denied pip virtualenv

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.

Can't install this Python module (IMDbPY) because of El Capitan? (Deprecation?)

So I'm trying to install IMDbPY with pip, but I'm getting the following warning in yellow font, followed by a bunch of warnings in red.
I've tried several commands to solve this and without luck. I've search for the warning in yellow (that starts with DEPRECATION) and have found a thread on Github detailing some changes with OS X El-Capitan and how the "six" package is affected, and I managed to install it independently, but it seems like IMDbPY still wants to uninstall for some reason?
Installing collected packages: six, sqlparse, decorator, Tempita, sqlalchemy-migrate, IMDbPY
Found existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 311, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 640, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 716, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 125, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 315, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-QNP1Pr-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
Any help appreciated!
From anyone who is still interested on this, you can install it from source without any errors.
Pip or easy_install didn't work for me either on El Capitan (at least when I installed it).
You can get the latest zip package on http://imdbpy.sourceforge.net/downloads.html#source-code.
I hope I helped.
If you use
pip install --user imdbpy
it will work. Did for me anyway.

Categories

Resources