1

Installing Ansible on the Mac (10.11.6) I get to the "installing Python modules" section here http://docs.ansible.com/ansible/intro_installation.html and get this error:

sudo pip install paramiko PyYAML Jinja2 httplib2 six

... lots of downloading ...

Installing collected packages: pyasn1, pycparser, cffi, setuptools, idna, ipaddress, enum34, cryptography, paramiko, PyYAML, MarkupSafe, Jinja2, httplib2
Running setup.py install for pycparser ... done
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-8.1.2-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_set.py", line 736, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_install.py", line 742, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-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 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-QJiMr7-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', "[Errno 1] Operation not permitted: '/tmp/pip-QJiMr7-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-QJiMr7-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-QJiMr7-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-QJiMr7-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', "[Errno 1] Operation not permitted: '/tmp/pip-QJiMr7-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-QJiMr7-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-QJiMr7-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-QJiMr7-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', "[Errno 1] Operation not permitted: '/tmp/pip-QJiMr7-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'")]

Any idea what the problem is?

3 Answers 3

0

If you don't mind user install, call pip install --user ansible and enjoy.
Mac OS has some troubles installing global packages after El Capitan upgrade.

0

There is a version conflict on USX with the installed version of six. The installed version (the version that comes with OSX) will work, but pip does not know it will work. Do not try to install six with pip. When you go to install Ansible, use the following command:

sudo -H pip install ansible --upgrade --ignore-installed six

This tells pip to ignore the conflict with six and assume the installed version will work.

1
  • There are actually a huge number of python packages which depend on six, so be aware of this option any time you run into any package which has a conflict with the OSX version
    – MillerGeek
    Aug 10, 2016 at 14:33
0

OSX recently made changes so that you will likely encounter (sooner or later) incompatibilities between python modules that reside on the system and stuff you need to install. Ansible is a good example as it has dependencies that no longer play nice with what's already installed.

The clean solution is to use a virtual environment: https://virtualenv.pypa.io/en/stable/userguide/#usage

Quite simply you are creating a bubble in which to install and run your version of python and its modules. It goes like so:

$ virtualenv myenv
New python executable in myenv/bin/python
Installing setuptools, pip...done.

$ ls -lah myenv
total 8
drwxr-xr-x   6 migueldavid  staff   204B 19 Aug 14:45 .
drwxr-xr-x+ 60 migueldavid  staff   2.0K 19 Aug 14:45 ..
lrwxr-xr-x   1 migueldavid  staff    63B 19 Aug 14:45 .Python -> /System/Library/Frameworks/Python.framework/Versions/2.7/Python
drwxr-xr-x  14 migueldavid  staff   476B 19 Aug 14:45 bin
drwxr-xr-x   3 migueldavid  staff   102B 19 Aug 14:45 include
drwxr-xr-x   3 migueldavid  staff   102B 19 Aug 14:45 lib

You then activate the virtual environment and install whatever you need:

$ source myenv/bin/activate
(myenv)$ pip install ansible
Downloading/unpacking ansible
  Downloading ansible-2.1.1.0.tar.gz (1.9MB): 1.9MB downloaded
(...)

To get out of this "sandbox", you simply have to type

$ deactivate

I hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.