PythonBeginnerMedium severity
ModuleNotFoundError: No module named ...
Python cannot resolve an imported package or local module in the active interpreter path.
3-10 min Popularity 97/100 Verified 2026-07-21
What does this error mean?
The import system searched the active environment and project path but did not find the requested top-level module.
Why does this happen?
- The package is not installed.
- The import name differs from the package installation name.
- The project is running from the wrong working directory.
- A virtual environment mismatch exists.
- A local package is missing an expected project configuration.
AI explanation
Plain-English analysis
The message names the import Python could not resolve. First determine whether it is a third-party package or your own module, then inspect the active interpreter and import path.
Quick fix
Terminal
python -c "import sys; print(sys.executable); print(*sys.path, sep='\n')"
Expected output: The output shows which interpreter and search paths Python is using.
Step-by-step fix
1Install the package into the active environmentUse the running interpreter to invoke pip.79%
Command
python -m pip install <package>
2Run the project as a moduleFor package-relative imports, run from the project root with `python -m package.module`.45%
3Fix the local package structureVerify package directories, project configuration, and import names.34%
Alternative solutions
Virtual environment
python -m venv .venv python -m pip install -r requirements.txt
Activate the environment before starting the application.
Editable local package
python -m pip install -e .
Use an editable install for a properly configured local package.
Real example
Broken
shell
from myapp.services import billing # executed from inside myapp/services
Corrected
shell
# From the project root: python -m myapp.cli
Frequently asked questions
The terminals are probably using different Python interpreters or virtual environments. Compare the output of `python -c "import sys; print(sys.executable)"` in both.