Common causes
- The package isn't installed: run pip install <package-name>
- Using the wrong Python environment — you installed the package globally but are running a virtual environment
- The virtual environment wasn't activated before running the script
- You installed with pip3 but are running python (which might point to Python 2 on some systems)
How to fix it
- Install the package: pip install <package-name> or python -m pip install <package-name>
- Check which Python is being used: which python or python --version
- Activate your virtual environment: source venv/bin/activate
- List installed packages to verify: pip list | grep <package>
Example
Traceback (most recent call last):
File "app.py", line 1, in <module>
from flask import Flask
ModuleNotFoundError: No module named 'flask'Running a Flask app without first installing Flask via pip install flask
Have a different error?
Paste any error message into the Error Translator to get an instant explanation.
