在 OS X 10.10 Yosemity 上,使用 安装 ansible 后brew
,我运行它,它立即崩溃,如下所示:
$ ansible
Traceback (most recent call last):
File "/usr/local/Cellar/ansible/1.6.10/libexec/bin/ansible", line 5, in <module>
pkg_resources.run_script('ansible==1.6.10', 'ansible')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 492, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1350, in run_script
execfile(script_filename, namespace, namespace)
File "/usr/local/Cellar/ansible/1.6.10/lib/python2.7/site-packages/ansible-1.6.10-py2.7.egg/EGG-INFO/scripts/ansible", line 25, in <module>
from ansible.runner import Runner
File "/usr/local/Cellar/ansible/1.6.10/lib/python2.7/site-packages/ansible-1.6.10-py2.7.egg/ansible/runner/__init__.py", line 32, in <module>
import jinja2
File "/usr/local/Cellar/ansible/1.6.10/libexec/lib/python2.7/site-packages/Jinja2-2.7.1-py2.7.egg/jinja2/__init__.py", line 33, in <module>
from jinja2.environment import Environment, Template
File "/usr/local/Cellar/ansible/1.6.10/libexec/lib/python2.7/site-packages/Jinja2-2.7.1-py2.7.egg/jinja2/environment.py", line 13, in <module>
from jinja2 import nodes
File "/usr/local/Cellar/ansible/1.6.10/libexec/lib/python2.7/site-packages/Jinja2-2.7.1-py2.7.egg/jinja2/nodes.py", line 18, in <module>
from jinja2.utils import Markup
File "/usr/local/Cellar/ansible/1.6.10/libexec/lib/python2.7/site-packages/Jinja2-2.7.1-py2.7.egg/jinja2/utils.py", line 520, in <module>
from markupsafe import Markup, escape, soft_unicode
File "/Library/Python/2.7/site-packages/markupsafe/__init__.py", line 14, in <module>
from markupsafe._compat import text_type, string_types, int_types, \
ImportError: No module named _compat
答案1
你似乎正在运行旧版本的 ansible,最新版本是 homebrew 中的 1.7.2。你是如何安装的?如果你使用 Homebrew 问题
brew upgrade ansible
看看是否有帮助。