Pytest says 'ModuleNotFoundError' when using tox

What helped me:

  1. Add missing modules to the install_requires section of the setup.py
  2. Delete old .tox directory and re-run tox

[tox]skipsdist = True prevents tox to run python setup.py sdist so your install_requires is completely ignored.

If you really want to follow the advice to set [tox]skipsdist = True for applications you are also advised to follow all other best practices for packaging applications: use requirements.txt and add

[testenv]
deps =
    -rrequirements.txt

to tox.ini. Or just directly

[testenv]
deps = python-dateutil

Tags:

Python

Pytest

Tox