24


当我尝试安装 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

有谁知道如何修理它?

4

5 回答 5

45

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

pip install pyyaml

如果pip你的mac上没有安装,那么你可以安装它,

easy_install pip

于 2014-01-07T14:38:28.483 回答
13

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

pip install pyyaml作品

于 2014-08-27T13:53:01.397 回答
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
于 2014-01-12T05:26:54.720 回答
1

尝试安装

sudo python -m easy_install pyyaml

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

于 2016-10-06T13:43:13.490 回答
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 安装

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
    >>>
于 2017-09-21T09:31:47.037 回答