ModuleNotFoundError: No module named 'pybind11_tests'

49 Views Asked by At

When running the pytest command at the root path of my project, I encounter this error. Since there are no SO question on how to solve this issue, I will provide an answer to my own question for others to benefit. Please see answer below.

1

There are 1 best solutions below

0
jsibs On

The above error is due to the OP running the pytest command at the root of their project, which will run the pybind11 tests. To mitigate this, ensure you exclude running your pybind11 test or be more specific the directories you are testing.

Please see reference from henry:

I habitually run python3 -m pytest tests, which forces the tests dir to be the only place searched. Without that, we aren't limiting the search locations, so it picks up extern/pybind11/tests, which it (obviously) should not pick up.

For now, you can add the tests part to your command, and we can add a pytest configuration option to disable searching for tests in /extern. I can help add that soon.

https://github.com/scikit-hep/boost-histogram/issues/312#issuecomment-591030455