ModuleNotFoundError: No module named
This error matches known, documented patterns with reliable solutions.
Quick Fix (Most Common Solution)
- Install with pip install module-name
- Activate correct virtual environment
Seeing "ModuleNotFoundError: No module named"? This error can be frustrating, but it's usually fixable. It typically affects your development workflow or system. Below you'll find clear, step-by-step solutions to resolve this issue.
What This Error Means
Python cannot find the module you are trying to import.
Frequently documented in developer and vendor support forums.
Not affiliated with browser, OS, or device manufacturers.
New here? Learn why exact error messages matter →
Common Causes
- Package not installed with pip
- Wrong Python environment active
- Typo in module name
How to Fix
- Install with pip install module-name
- Activate correct virtual environment
- Check module name spelling
Last reviewed: March 2026 How we review solutions
Version note: Especially common after macOS Sonoma and Ventura updates, which may reset or relocate the system Python. Also frequent when switching between Python 3.8–3.12 due to renamed or removed stdlib modules.
Environment-Specific Commands
Linux
python3 -m pip install module-nameIf using system Python: sudo apt install python3-module-nameOr create a venv: python3 -m venv .venv && source .venv/bin/activate
macOS
python3 -m pip install module-nameIf Homebrew Python: ensure /opt/homebrew/bin is in PATHpyenv users: pyenv rehash after installing packages
Windows
py -m pip install module-nameIf multiple Python versions: py -3.11 -m pip install module-nameCheck PATH: where python should show your expected Python
Quick Diagnostic Path
- If pip install succeeds but import still fails → Run python -c "import sys; print(sys.executable)" to confirm pip and python point to the same installation
- If Works in terminal but fails in IDE → Check IDE Python interpreter setting — it may point to a different environment
- If Error only in deployed/production environment → Ensure requirements.txt is complete: pip freeze > requirements.txt and redeploy
If This Still Fails, Check
- Module name differs from pip package name (e.g., import cv2 but pip install opencv-python)
- Jupyter notebook using a different kernel than your terminal — run !pip install inside the notebook to match
- Namespace packages (no __init__.py) can cause this in Python 3.3+ if the directory structure is wrong
Diagnosing mismatched pip and python
# Check which python is running
python3 -c "import sys; print(sys.executable)"
# /usr/bin/python3
# Check which pip is installing to
python3 -m pip --version
# pip 23.1 from /usr/lib/python3/dist-packages/pip
# Always use python3 -m pip to guarantee match
python3 -m pip install requestsOptional follow-up
Some users ask whether saving fixes for recurring errors would be useful when the same issue appears again.
Was this explanation helpful?
Frequently Asked Questions
Why is pip-installed module not found?
You may be using a different Python/pip than expected. Use pip3 or python -m pip.
How do I check installed packages?
Run pip list or pip freeze to see installed packages.
Related Resources
Also Known As
- Python exception
- Python traceback
- Python runtime error
- Python crash
Common Search Variations
- "python error fix"
- "python script not working"
- "python traceback what does it mean"
- "how to fix python exception"
- "python crash on startup"
- "python import error solution"
Related Errors
Still Stuck?
Paste a different error message or upload a screenshot to get help instantly.