How to Fix Python ModuleNotFoundError
Fix ModuleNotFoundError and No module named errors in Python by checking your environment, paths, and imports.
ModuleNotFoundError: No module named 'foo' means Python can't find the
package on its import path.
Checklist
- Is it installed?
pip show foo - Are you using the right environment?
which python/python -m pip - Did you name a local file the same as a stdlib module (e.g.
email.py)?
Never name your script requests.py or test.py — it shadows the real
package and breaks imports in confusing ways.
Install and verify
python -m pip install foo
python -c "import foo; print(foo.__version__)"AdSense — in-article slot