millisami
millisami

Reputation: 10161

ImportError: cannot import name CSafeLoader

Installed all the dependencies for juju

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

All installed fine but when I start juju, fails with the following error:

(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

What is this error? I'm on Mac 10.6, python and pip installed via homebrew.

Upvotes: 1

Views: 2950

Answers (2)

tianzhipeng
tianzhipeng

Reputation: 2209

Face with this problem in 2024 :( record my operations for later:

brew install libyaml
export LDFLAGS="-L/opt/homebrew/Cellar/libyaml/0.2.5/lib/"
export CFLAGS="-I/opt/homebrew/Cellar/libyaml/0.2.5/include/"

pip --no-cache-dir install --verbose --global-option='--with-libyaml' --force-reinstall -I pyyaml

then from yaml import CSafeLoader success

Upvotes: 0

bokonic
bokonic

Reputation: 1771

I just ran into this issue on 10.8; juju uses the libyaml bindings in PyYaml, so it needs to have PyYaml installed --with-libyaml, which requires more than that on the mac. Here's how I got it working:

  • brew install libyaml with homebrew
  • Download PyYaml source (instructions)

Now modify [pyyaml-install-dir]/setup.cfg like this:

# 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/

So it can find your homebrew installation of libyaml. Then you also need to install Cython..

  • sudo pip install cython

and finally..

  • sudo python setup.py --with-libyaml install (in the PyYaml dir)

Now juju should work!

Upvotes: 3

Related Questions