I am attempting to run a group of automated tests with Pytest. I receive a ModuleNotFoundError that prevents me from importing other python modules. What do I need to do in order to make the module import?
Directory '/Users/jordonpeterson/code/gateway_tests' is in your sys.path, so importing the module with `import tests.gateway_alpha_login` instead of `import gateway_alpha_login` should work. Have you tried this?
If this is not working, you can add directory ''/Users/jordonpeterson/code/gateway_tests/tests' to the PYTHONPATH variable in your run configuration. Open the run/debug configuration and create environment variable PYTHONPATH with the value '/Users/jordonpeterson/code/gateway_tests/tests'.
Ensure that checkboxes "Add content roots to PYTHONPATH" and "Add source roots to PYTHONPATH" are enabled.
This way the interpreter should know where to look for the module.
Hi
Most likely the issue is with your environment. Please open python console and post the output of:
import sys
sys.path
You can also try to change the import statement in your code
import tests.gateway_alpha_login
I went through those steps and this is the result.
['/Users/jordonpeterson/Library/Application Support/IntelliJIdea2018.3/python/helpers/pydev', '/Users/jordonpeterson/Library/Application Support/IntelliJIdea2018.3/python/helpers/third_party/thriftpy', '/Users/jordonpeterson/Library/Application Support/IntelliJIdea2018.3/python/helpers/pydev', '/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages', '/Users/jordonpeterson/Library/Application Support/IntelliJIdea2018.3/python/helpers/pycharm_matplotlib_backend', '/Users/jordonpeterson/code/gateway_tests']
Directory '/Users/jordonpeterson/code/gateway_tests' is in your sys.path, so importing the module with `import tests.gateway_alpha_login` instead of `import gateway_alpha_login` should work. Have you tried this?
If this is not working, you can add directory ''/Users/jordonpeterson/code/gateway_tests/tests' to the PYTHONPATH variable in your run configuration. Open the run/debug configuration and create environment variable PYTHONPATH with the value '/Users/jordonpeterson/code/gateway_tests/tests'.
Ensure that checkboxes "Add content roots to PYTHONPATH" and "Add source roots to PYTHONPATH" are enabled.
This way the interpreter should know where to look for the module.