Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: ImportError: No module named yaml #81

Open
klemens-u opened this issue May 12, 2020 · 4 comments
Open

Error: ImportError: No module named yaml #81

klemens-u opened this issue May 12, 2020 · 4 comments

Comments

@klemens-u
Copy link

Using Ubuntu 18.04 I get the following error:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named yaml
fatal: [my-host]: FAILED! => changed=false 
  module_stderr: |-
    Traceback (most recent call last):
      File "<stdin>", line 114, in <module>
      File "<stdin>", line 106, in _ansiballz_main
      File "<stdin>", line 49, in invoke_module
      File "/tmp/ansible_yedit_payload_fkAMVf/__main__.py", line 191, in <module>
    ImportError: No module named yaml
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

I already tried various variants of pip install pyaml, (python2, python3, earlier version) but to no success. Any ideas?

@klemens-u
Copy link
Author

Note: this happens only with python2

@denisli2017
Copy link

denisli2017 commented Sep 6, 2020

I guess the package needed might be ruamel.yaml. But tried it no help too.

@jasperroloff
Copy link

Hey, I had the same problem.

Installing the package python-yaml did it for me.

You can do this by running apt install python-yaml on the managed host or by creating an ansible task:

- name: ensure python-yaml is installed
  package:
    name: python-yaml
    state: present

@noziwatele
Copy link

I had this issue in python3 using pyenv virtual environments on Macos. It seems like the correct python interpreter was not discovered. Fixed by setting the ANSIBLE_PYTHON_INTERPRETER environment variable as follows.

export ANSIBLE_PYTHON_INTERPRETER="$(which python)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants