ImportError:无法导入名称CSafeLoader

时间:2013-03-19 13:19:41

标签: python-2.7 pip

安装了juju的所有依赖项

pip install pyparsing==1.5.7
pip install pyOpenSSL PyYAML txaws pydot oauth txzookeeper zc-zookeeper-static
pip install juju

所有安装正常,但是当我启动juju时,失败并出现以下错误:

(jujuapp) ± juju                                                                                           
Traceback (most recent call last):
  File "/Users/millisami/.virtualenvs/jujuapp/bin/juju", line 4, in <module>
    from juju.control import main
  File "/Users/millisami/.virtualenvs/jujuapp/lib/python2.7/site-packages/juju/control/__init__.py", line 7, in <module>
    from .utils import ParseError
  File "/Users/millisami/.virtualenvs/jujuapp/lib/python2.7/site-packages/juju/control/utils.py", line 8, in <module>
    from juju.state.environment import EnvironmentStateManager
  File "/Users/millisami/.virtualenvs/jujuapp/lib/python2.7/site-packages/juju/state/environment.py", line 8, in <module>
    from juju.environment.config import EnvironmentsConfig
  File "/Users/millisami/.virtualenvs/jujuapp/lib/python2.7/site-packages/juju/environment/config.py", line 8, in <module>
    from juju.lib import serializer
  File "/Users/millisami/.virtualenvs/jujuapp/lib/python2.7/site-packages/juju/lib/serializer.py", line 1, in <module>
    from yaml import CSafeLoader, CSafeDumper, Mark
ImportError: cannot import name CSafeLoader

这是什么错误? 我通过自制软件安装Mac 10.6,python和pip。

1 个答案:

答案 0 :(得分:3)

我刚刚在10.8遇到了这个问题; juju在PyYaml中使用了libyaml绑定,因此它需要安装PyYaml --with-libyaml,这需要比mac上的更多。以下是我如何运作:

  • brew install libyaml with homebrew
  • 下载PyYaml源代码(instructions

现在像这样修改[pyyaml-install-dir]/setup.cfg

# List of directories to search for 'yaml.h' (separated by ':').
include_dirs=/usr/local/Cellar/libyaml/0.1.4/include/

# List of directories to search for 'libyaml.a' (separated by ':').
library_dirs=/usr/local/Cellar/libyaml/0.1.4/lib/

所以它可以找到你自制的libyaml安装。然后您还需要安装Cython ..

  • sudo pip install cython

最后..

  • sudo python setup.py --with-libyaml install(在PyYaml目录中)

现在juju应该工作了!