Update setuptools on OSX El Capitan

I am trying to update setuptools. Well, I'm actually trying to upgrade, but it is trying to update setuptools and fail. Attempting to do this alone also fails. Even trying to delete it does not work

$ sudo -H pip install --upgrade setuptools Collecting setuptools Using cached setuptools-18.4-py2.py3-none-any.whl Installing collected packages: setuptools Found existing installation: setuptools 1.1.6 Uninstalling setuptools-1.1.6: Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/basecommand.py", line 211, in main status = self.run(options, args) File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/commands/install.py", line 311, in run root=options.root_path, File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_set.py", line 640, in install requirement.uninstall(auto_confirm=True) File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_install.py", line 716, in uninstall paths_to_remove.remove(auto_confirm) File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_uninstall.py", line 125, in remove renames(path, new_path) File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/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 299, in move copytree(src, real_dst, symlinks=True) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 208, in copytree raise Error, errors Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', '/tmp/pip-OyTXsR-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', "[Errno 1] Operation not permitted: '/tmp/pip-OyTXsR-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', '/tmp/pip-OyTXsR-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-OyTXsR-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/tmp/pip-OyTXsR-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', "[Errno 1] Operation not permitted: '/tmp/pip-OyTXsR-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/tmp/pip-OyTXsR-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-OyTXsR-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/tmp/pip-OyTXsR-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', "[Errno 1] Operation not permitted: '/tmp/pip-OyTXsR-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'")] 

I have no vague idea of ​​what's wrong. View all files in /System/Library/Frameworks/Python.framework/Versions/2.7/ and below each file belongs to root:wheel

How can i fix this?

+70
setuptools macos
Oct 20 '15 at 10:50
source share
3 answers

This is due to system integrity protection introduced in OS X El Capitan.

Adding --user python to the command allowed this to work.

In other words

 pip install --upgrade setuptools --user python 
+167
Nov 13 '15 at 7:38
source share

The answer is that you cannot update setuptools in OSX for the peony factory that comes with the OS. The reason is that the files in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python cannot be deleted or modified by the user. Not only an ordinary user, but even if you have root privileges, you cannot modify these files.

Of course, you can use various other methods to install a newer version of setuptools, but this will not override the default system package. If you go along the suggested route of using the --user python flag or you want to install them without root in ~/Library , they will not override the version of system files.

The reason you or the root cannot change the system defaults is due to the limitations of SIP permissions in El Capitan +. You can disable SIP, but this is usually not recommended.

Instead, the only smart solution is to use virtual virtual python.

+1
Oct 10 '16 at 19:01
source share

Overview

The problem is conflicting Python libraries in combination with System Integrity Protection (SIP) on Mac OS, which protects Python library systems.

The best solution, in my opinion, is to uninstall and reinstall your own Python installation and save this in the Python libraries provided by Mac OS, which are protected by SIP.

I recommend disabling SIP because I expect SIP to be part of any future releases of Mac OS and SIP is not the reason here, it just reveals the problem of conflicting Python libraries.

More details

I also had a problem with setting permissions.

My problem started when I followed the installation instructions for Mac OS, which you need to install through pip and install pip using easy_install , as described in Recent Via Pip releases

The problem is that when pip is installed, this easy_install path is the Mac OS provided by easy_install in /usr/bin/easy_install , but it writes to the easy-install.pth in /Library/Python/2.7/site-packages/easy-install.pth and this file refers to Mac OS provided by Python libraries.

Then installation is possible with pip install ansible , after which it reports that the setuptools requirement is satisfied by the Mac OS Python library provided in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Ansible requires setuptools but does not specify a version. Another paramiko dependent package requires setuptools> = 11.3, but this does not seem to be checked when installing accessible via pip. When you try to run the program, although it complains that the installation tools are 1.1.6. This is the version of setuptools that ships with Mac OS and is now SIP protected, so it cannot be updated.

Instead of disabling SIP, I fixed this by deleting my local Python, as shown at https://docs.python.org/2.7/using/mac.html#getting-and-installing-macpython and then downloading again and again and install.

If rm bothers you, you can mv instead. To remove, I did

 sudo rm -rf /Library/Python sudo rm -rf /Applications/Python\ 2.7/ sudo rm /usr/local/bin/ansible # executable sudo rm /usr/local/bin/python* # symlinks to /Library/Python/2.7 sudo rm /usr/local/bin/easy_install* # and so on for references to /Library/Python/2.7 in /usr/local/bin 

Then I downloaded the installation package 2.7.13 for Mac OS X from https://www.python.org/downloads/ and installed it.

This set the local python and pip to /Library/Frameworks/Python.framework/Versions/2.7 and the symbolic links in /usr/local/bin , as well as adding /Library/Frameworks/Python.framework/Versions/2.7 to my $ PATH. This allows me to store everything separately from the Mac OS libraries in /System/Library/Frameworks/Python.framework and /usr/bin so that I get

 which pip /Library/Frameworks/Python.framework/Versions/2.7/bin/pip 

Then I installed the option using pip install ansible
Then when I run which ansible , I get

 /Library/Frameworks/Python.framework/Versions/2.7/bin/ansible 

and in pip list

 setuptools (28.8.0) six (1.10.0) 

and now it works because on Mac OS Python the new installation is not referenced.

Note that due to the installation of the installer $ PATH which python now /Library/Frameworks/Python.framework/Versions/2.7/bin/python and /usr/local/bin/python is a symbolic link to this.
If you want to use the Python system, you will have to use / usr / bin / python or change $ PATH

0
Mar 05 '17 at 12:11
source share



All Articles