ModuleNotFoundError: No module named '...'
When Python raises ModuleNotFoundError: No module named '...', it means the import statement cannot find the requested module anywhere in the module search path.
What It Means
Python looks for modules in sys.path — a list of directories that includes the script’s directory, the standard library, and site-packages. If the module isn’t in any of these locations, this error is raised.
Why It Happens
- The module isn’t installed (
pip installneeded) - You’re in the wrong virtual environment (or none at all)
- The module is installed for a different Python version (e.g. Python 2 vs 3)
- The script is running from a directory that shadows the module name
- A custom script has the same name as the module you’re trying to import
How to Fix It
Step 1: Install the missing module
pip install <module-name>For specific versions:
pip install <module-name>==1.2.3Step 2: Activate your virtual environment
If you created a virtual environment but forgot to activate it:
# On Linux/macOS:
source venv/bin/activate
# On Windows:
venv\Scripts\activateStep 3: Check Python version compatibility
Some modules only support certain Python versions:
# Check which Python you're using
python --version
# Install for your specific Python version
python3.11 -m pip install <module-name>Step 4: Inspect the module search path
import sys
print(sys.path)Make sure the directory containing your module appears in this list.
Step 5: Rename conflicting scripts
If you named your script the same as the module (e.g. requests.py), rename it — Python will import your script instead of the real module.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro