Ansible-galaxy抛出ImportError:没有名为yaml的模块

时间:2014-01-07 08:21:30

标签: macos ansible ansible-galaxy


当我尝试安装ansible角色时,我看到了这个异常。

 $ ansible-galaxy install zzet.postgresql
 Traceback (most recent call last):
 File "/Users/myHomeDir/.homebrew/Cellar/ansible/1.4.3/libexec/bin/ansible-galaxy", line 34, in <module>
 import yaml
 ImportError: No module named yaml
操作系统:Mac Os Maverick
Ansible:1.4.3

有谁知道如何修复它?

5 个答案:

答案 0 :(得分:45)

根据错误消息,它尝试导入python模块yaml但找不到它。使用pyyaml安装yaml模块时会调用pip

pip install pyyaml

如果您的Mac上未安装pip,则可以将其安装为

easy_install pip

答案 1 :(得分:13)

对我来说pip install yaml在小牛队中不起作用。

pip install pyyaml有效

答案 2 :(得分:1)

我尝试了pip install yaml答案,但它对我不起作用。我不得不重新安装ansible以便命令行捕获。 IE,

<强>失败

ansible-galaxy install bcen01.nodejs                          [43m] ✭
Traceback (most recent call last):
  File "/usr/local/Cellar/ansible/1.4.3/libexec/bin/ansible-galaxy", line 34, in <module>
    import yaml
ImportError: No module named yaml

<强>重装

brew reinstall ansible

<强>成功

ansible-galaxy install bcen01.nodejs                          [43m] ✭
 no version specified, installing master
 - downloading role from https://github.com/bcen/ansible-nodejs/archive/master.tar.gz
 - extracting bcen01.nodejs to /usr/local/etc/ansible/roles/bcen01.nodejs
bcen01.nodejs was installed successfully

答案 3 :(得分:1)

尝试使用

进行安装

sudo python -m easy_install pyyaml

问题不在pyyaml中,而是在你的setuptools版本中。有关参考资料,请参阅http://codyaray.com/2011/12/pyyaml-using-easy_install-on-mac-os-x-lion

答案 4 :(得分:0)

运行以下命令以安装最新的yaml -

wget http://pyyaml.org/download/pyyaml/PyYAML-3.12.tar.gz

tar -xvzf PyYAML-3.12.tar.gz

cd PyYAML-3.12

python setup.py install

Python 2.7.12 (default, Sep 21 2017, 21:46:26)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.

    >>> import yaml
    >>>