question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot load CLoader

See original GitHub issue

Hi, I’m using pyyaml in a Docker container based on bitnami/minideb:jessie, where python version is 2.7.9.

The original code is using CLoader and I cannot change it. Any reason CLoader fails to load but Loader is fine ?

>>> import yaml
>>> yaml.__version__ '3.12'
>>> from yaml import Loader
>>> from yaml import CLoader Traceback (most recent call last):   File "<stdin>", line 1, in <module> ImportError: cannot import name CLoader 
>>>

I cannot figure out what I’m missing here. Any idea ?

Running it from the Docker image python:2.7.9 does not raise any error then:

$ docker run -ti python:2.7.9 bash
#/ python
>>> from yaml import CLoader
>>> from yaml import Loader
>>>

Thanks for your help.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
immerrrcommented, Jul 8, 2020

This is because cyaml is optional and requires build dependencies, such as cython and yaml.h to be available upon building the package (yaml.h comes from libyaml-dev package in Debian/Ubuntu):

This is what it prints when libyaml-dev is not found when running $ pip --no-cache-dir install --verbose --force-reinstall -I pyyaml

<....>
    running build_ext
    creating build/temp.linux-x86_64-2.7
    checking if libyaml is compilable
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/immerrr/.conda/envs/loc-des/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.linux-x86_64-2.7/check_libyaml.o
    build/temp.linux-x86_64-2.7/check_libyaml.c:2:18: fatal error: yaml.h: No such file or directory
    compilation terminated.

    libyaml is not found or a compiler error: forcing --without-libyaml
    (if libyaml is installed correctly, you may need to
     specify the option --include-dirs or uncomment and
     modify the parameter include_dirs in setup.cfg)
<..finishes up right away..>

And this is what you’ll see if everything is set up fine:

<....>
    checking if libyaml is compilable
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/immerrr/.conda/envs/loc-des/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.linux-x86_64-2.7/check_libyaml.o
    checking if libyaml is linkable
    gcc -pthread build/temp.linux-x86_64-2.7/check_libyaml.o -L/home/immerrr/.conda/envs/loc-des/lib -lyaml -o build/temp.linux-x86_64-2.7/check_libyaml
    building '_yaml' extension
<..proceeds to build the extension..>
2reactions
jonas-eschlecommented, May 21, 2018

Thanks for the fix! This worked. But I would propose to add such a statement directly in the error message. So if cyaml cannot be compiled but is accessed, it should not just be an attribute not found-error but rather a message telling the above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot load CLoader with pyyaml - python - Stack Overflow
The original code is using CLoader and I cannot change it currently. Any reason CLoader fails to load but Loader is fine ?...
Read more >
yamlloader - PyPI
This module provides loaders and dumpers for PyYAML. Currently, an OrderedDict loader/dumper is implemented, allowing to keep items order when loading resp.
Read more >
PyYAML Documentation
Therefore it is not safe to use Loader to load a document received from an untrusted source. By default, the functions scan ,...
Read more >
WP Toolkit shows error: Cannot load the ionCube PHP Loader
WP Toolkit shows error: Cannot load the ionCube PHP Loader – it was already loaded - Support Cases - Plesk Knowledge Base.
Read more >
Error: Cannot load into non simple data - Esri Support
This error occurs when the Simple Data Loader is used to load data into a feature class in a relationship class, geometric network,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found