ModuleNotFoundError: No module named
What it means
Python looked for the module in your import line and could not find one with that name. Most often the name is misspelt or has the wrong capital letters. For a third-party library it can also mean the library is not installed, or that its import name differs from the name you install it by.
1. A misspelt module name
This raises the error
Traceback (most recent call last): File "<exec>", line 1, in <module> ModuleNotFoundError: No module named 'maths'
The fix
4.0
The standard module is math, without an s. Python matches module names letter for letter, so one extra letter is enough to miss it.
2. Wrong capital letters
This raises the error
Traceback (most recent call last): File "<exec>", line 1, in <module> ModuleNotFoundError: No module named 'Json'
The fix
{"name": "Ana"}Module names are case sensitive, and almost all standard ones are lowercase: json, random, datetime.
3. Importing a class from a module with a dot
This raises the error
Traceback (most recent call last): File "<exec>", line 1, in <module> ModuleNotFoundError: No module named 'datetime.date'; 'datetime' is not a package
The fix
2026-10-18
import a.b works only when b is a module inside a package. date is a class inside the datetime module, so write from datetime import date.
When you see this error, check
- Check the spelling and capital letters of the name in the
importline. - Use
from module import namefor functions and classes inside a module. - For a third-party library, use its import name: you install
pillowbut writeimport PIL, and installscikit-learnbut writeimport sklearn. - On pythoncompiler.io, numpy, pandas, matplotlib, scipy, scikit-learn, seaborn and Pillow load by themselves when you import them. On your own computer, install a library with
pip installfirst.
Related errors
All Python errors · How to read a traceback · Step through your code