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