Molecule: UnboundLocalError: local variable 'requests' referenced before assignment

Created on 26 Apr 2020  路  1Comment  路  Source: ansible-community/molecule




Issue Type

  • Bug report

Molecule and Ansible details

  • Latest

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Desired Behavior

When docker python dependency is not installed an error message is shown not a stack trace.

Actual Behaviour

--> Sanity checks: 'docker'
Traceback (most recent call last):
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/molecule/driver/docker.py", line 223, in sanity_checks
    import docker
ModuleNotFoundError: No module named 'docker'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/foobar/work/barfoo/infrastructure/.venv/bin/molecule", line 8, in <module>
    sys.exit(main())
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/molecule/command/test.py", line 147, in test
    base.execute_cmdline_scenarios(scenario_name, args, command_args)
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/molecule/command/base.py", line 107, in execute_cmdline_scenarios
    execute_scenario(scenario)
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/molecule/command/base.py", line 149, in execute_scenario
    execute_subcommand(scenario.config, action)
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/molecule/command/base.py", line 138, in execute_subcommand
    return command(config).execute()
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/molecule/command/destroy.py", line 107, in execute
    self._config.provisioner.destroy()
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/molecule/provisioner/ansible.py", line 700, in destroy
    pb.execute()
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/molecule/provisioner/ansible_playbook.py", line 105, in execute
    self._config.driver.sanity_checks()
  File "/home/foobar/work/barfoo/infrastructure/.venv/lib/python3.8/site-packages/molecule/driver/docker.py", line 228, in sanity_checks
    except requests.exceptions.ConnectionError:
UnboundLocalError: local variable 'requests' referenced before assignment
bug

Most helpful comment

Resolved by pip install docker==4.2.0 btw.

>All comments

Resolved by pip install docker==4.2.0 btw.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

beenje picture beenje  路  4Comments

decentral1se picture decentral1se  路  3Comments

srizzling picture srizzling  路  3Comments

tadeboro picture tadeboro  路  4Comments

surfer190 picture surfer190  路  3Comments