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.

【v5.4】partially initialized module 'yaml' has no attribute '__with_libyaml__'

See original GitHub issue

Hi there, Thank you for releasing the new version 5.4. When I imported version 5.4, I found the following error and would like to report it.

2021-01-20 12:23:20 import yaml
2021-01-20 12:23:20 File "/root/.local/lib/python3.8/site-packages/yaml/__init__.py", line 13, in <module>
2021-01-20 12:23:20 from .cyaml import *
2021-01-20 12:23:20 File "/root/.local/lib/python3.8/site-packages/yaml/cyaml.py", line 7, in <module>
2021-01-20 12:23:20 from _yaml import CParser, CEmitter
2021-01-20 12:23:20 File "/usr/local/lib/python3.8/site-packages/_yaml/__init__.py", line 8, in <module>
2021-01-20 12:23:20 if not yaml.__with_libyaml__:
2021-01-20 12:23:20 AttributeError: partially initialized module 'yaml' has no attribute '__with_libyaml__' (most likely due to a circular import)

The reproduced environment is python: 3.8-slim docker image.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:23 (14 by maintainers)

github_iconTop GitHub Comments

4reactions
nitzmahonecommented, Jan 20, 2021

Release 5.4.1 in flight with the fix.

3reactions
thanos1983commented, Jan 20, 2021

upgrading pyyaml version in requirements.txt file fixed this issue for me. PyYAML==5.4

For me actually going from PyYAML==5.2.1 to 5.4 broke my ansible.

The solution was to revert to 5.3.

Sample of problem:

$ ansible --version
Traceback (most recent call last):
  File "/usr/local/bin/ansible", line 62, in <module>
    import ansible.constants as C
  File "/home/<user>/.local/lib/python3.8/site-packages/ansible/constants.py", line 15, in <module>
    from ansible.config.manager import ConfigManager, ensure_type, get_ini_config_value
  File "/home/<user>/.local/lib/python3.8/site-packages/ansible/config/manager.py", line 17, in <module>
    from yaml import load as yaml_load
  File "/home/<user>/.local/lib/python3.8/site-packages/yaml/__init__.py", line 13, in <module>
    from .cyaml import *
  File "/home/<user>/.local/lib/python3.8/site-packages/yaml/cyaml.py", line 7, in <module>
    from _yaml import CParser, CEmitter
  File "/usr/local/lib/python3.8/dist-packages/_yaml/__init__.py", line 8, in <module>
    if not yaml.__with_libyaml__:
AttributeError: partially initialized module 'yaml' has no attribute '__with_libyaml__' (most likely due to a circular import)
$ sudo -H python3 -m pip install PyYAML==5.3
Collecting PyYAML==5.3
Installing collected packages: PyYAML
  Found existing installation: PyYAML 5.4
    Uninstalling PyYAML-5.4:
      Successfully uninstalled PyYAML-5.4
Successfully installed PyYAML-5.3
$ python3 -V
Python 3.8.7
$ ansible --version
ansible 2.10.4
  config file = /home/<user>/cookbook/ansible.cfg
  configured module search path = ['/home/<user>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/<user>/.local/lib/python3.8/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.7 (default, Dec 21 2020, 20:10:35) [GCC 7.5.0]

Hope this helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

module 'yaml' has no attribute 'FullLoader' - Stack Overflow
Keep in mind that pip's dependency resolver does not currently take into account all the packages that are installed for a given application....
Read more >
PyYAML is a YAML parser and emitter for Python.
PyYAML is a YAML parser and emitter for Python. Overview. YAML is a data serialization format designed for human readability and interaction with...
Read more >
yaml reader python | The AI Search Engine You Control
This article teaches you how to load, read, and write YAML files with PyYAML. In addition, you'll learn how to install it on...
Read more >
[Solved] AttributeError: 'module' object has no attribute
Click here to subscribe - https://www.youtube.com/channel/UCeVMnSShP_Iviwkknt83cww▻Instagram ...
Read more >
Zentyal 2.2 Changelog - Zentyal Linux Small Business Server
modal boxes in foreign selectors * Each module can have now its ... Delete no longer needed workaround for gconf with "removed" attribute...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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