I keep getting "no module named 'module.py'" after installing the package. How do I fix this?

Asked 2 years ago

I've recently made the switch to Python 3, and I'm having a hard time importing "module.py" - the error message says "ModuleNotFoundError: No module named module.py". What's the problem here?

Santino Vargas

Thursday, October 06, 2022

Keep in mind that Python has two types of imports - relative and absolute imports. If you're using absolute imports, make sure to set your Python path like this "export PYTHONPATH='PYTHONPATH:/.../" for MacOS and Linux, or set "PYTHONPATH=..." for Windows. If absolute imports don't work, then relative probably will. Make sure to try them both out and see which one doesn't trigger the error.





Write an answer...

Cancel

Please follow our  Community Guidelines

Can't find what you're looking for?