kwoodson / ansible-role-yedit

Ansible Role for Yaml editing
164 stars 62 forks source link

Error: ImportError: No module named yaml #81

Open klemens-u opened 4 years ago

klemens-u commented 4 years ago

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 commented 4 years ago

Note: this happens only with python2

denisli2017 commented 4 years ago

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

jasperroloff commented 4 years ago

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 commented 2 years ago

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)"