M上的Ansible安装错误

2024-09-27 21:29:05 发布

您现在位置:Python中文网/ 问答频道 /正文

在Mac上安装Ansible(10.11.6),我进入“安装Python模块”部分http://docs.ansible.com/ansible/intro_installation.html并得到以下错误:

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'")]

知道问题出在哪里吗?在


Tags: pippyextrasliblinelibraryframeworkversions
3条回答

OSX最近做了一些更改,因此您可能会(迟早)遇到驻留在系统中的python模块与您需要安装的东西之间的不兼容。 Ansible是一个很好的例子,因为它的依赖关系不再适合于已经安装的内容。在

干净的解决方案是使用虚拟环境: https://virtualenv.pypa.io/en/stable/userguide/#usage

很简单,您正在创建一个气泡,在其中安装和运行您的python版本及其模块。事情是这样的:

$ 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

然后激活虚拟环境并安装所需的任何内容:

^{pr2}$

要离开这个“沙盒”,你只需输入

$ deactivate

我希望这有帮助。在

如果您不介意用户安装,请致电pip install user ansible并享受。
Mac OS在El Capitan升级后安装全球软件包时遇到一些问题。在

USX上的版本与已安装的版本6存在版本冲突。安装的版本(OSX附带的版本)可以工作,但是pip不知道它能工作。不要试图用pip安装6。在安装Ansible时,请使用以下命令:

sudo -H pip install ansible  upgrade  ignore-installed six

这告诉pip忽略与six的冲突,并假设安装的版本可以工作。在

相关问题 更多 >

    热门问题