Skip to content

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

  1. Is it installed? pip show foo
  2. Are you using the right environment? which python / python -m pip
  3. 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

Related Reading