Molecule: No module named 'molecule'

Created on 12 Mar 2019  ·  3Comments  ·  Source: ansible-community/molecule

When going through the getting started guide test sequence the playbook fails with the following error:

$ python3.7 -m molecule create
--> Validating schema /Users/xxx/yyyy/ansible-molecule/test-role/molecule/default/molecule.yml.
Validation completed successfully.
--> Test matrix

└── default
    ├── create
    └── prepare

--> Scenario: 'default'
--> Action: 'create'
 [WARNING]: Skipping plugin
(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-
packages/molecule/provisioner/ansible/plugins/filters/molecule_core.py) as it
seems to be invalid: No module named 'molecule'


    PLAY [Create] ******************************************************************

    TASK [Log into a Docker registry] **********************************************
    fatal: [localhost]: FAILED! => {"msg": "An unhandled exception occurred while templating '{{ lookup('file', molecule_file) | molecule_from_yaml }}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: template error while templating string: no filter named 'molecule_from_yaml'. String: {{ lookup('file', molecule_file) | molecule_from_yaml }}"}

    PLAY RECAP *********************************************************************
    localhost                  : ok=0    changed=0    unreachable=0    failed=1   

ERROR: 

Issue Type

  • Bug report

Molecule and Ansible details

ansible 2.7.6
  config file = None
  configured module search path = ['/Users/stephen/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ansible
  executable location = /Library/Frameworks/Python.framework/Versions/3.6/bin/ansible
  python version = 3.6.6 (v3.6.6:4cf1f54eb7, Jun 26 2018, 19:50:54) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
molecule, version 2.20.0.0a2

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Desired Behavior

molecule should be available

Actual Behaviour

It fails

bug

Most helpful comment

Hi; I ran into this problem as well while going through the test sequence, but found the answer (different from above):

# Fresh install on MacOS:
brew install ansible molecule
molecule init role my-new-role
cd my-new-role
docker run hello-world # Make sure "Docker desktop" is installed and running
molecule create   # Error!

sudo pip3 install molecule-containers
sudo pip3 install docker-py
molecule create  # Success!
molecule test  # Success!

All 3 comments

Whoops, my mistake. I used a virtualenv to ensure molecule was installed correctly and it was.

Hi @surfer190, if you think we can improve the documentation, please send us a PR!

Happy hacking :rocket:

Hi; I ran into this problem as well while going through the test sequence, but found the answer (different from above):

# Fresh install on MacOS:
brew install ansible molecule
molecule init role my-new-role
cd my-new-role
docker run hello-world # Make sure "Docker desktop" is installed and running
molecule create   # Error!

sudo pip3 install molecule-containers
sudo pip3 install docker-py
molecule create  # Success!
molecule test  # Success!
Was this page helpful?
0 / 5 - 0 ratings