Editor

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

Broken
import maths
print(maths.sqrt(16))
Output
Traceback (most recent call last):
  File "<exec>", line 1, in <module>
ModuleNotFoundError: No module named 'maths'

The fix

Fixed
import math
print(math.sqrt(16))
Output
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.

Try fixing it yourself in the editor

2. Wrong capital letters

This raises the error

Broken
import Json
print(Json.dumps({'name': 'Ana'}))
Output
Traceback (most recent call last):
  File "<exec>", line 1, in <module>
ModuleNotFoundError: No module named 'Json'

The fix

Fixed
import json
print(json.dumps({'name': 'Ana'}))
Output
{"name": "Ana"}

Module names are case sensitive, and almost all standard ones are lowercase: json, random, datetime.

Try fixing it yourself in the editor

3. Importing a class from a module with a dot

This raises the error

Broken
import datetime.date
print(datetime.date(2026, 10, 18))
Output
Traceback (most recent call last):
  File "<exec>", line 1, in <module>
ModuleNotFoundError: No module named 'datetime.date'; 'datetime' is not a package

The fix

Fixed
from datetime import date
print(date(2026, 10, 18))
Output
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.

Try fixing it yourself in the editor

When you see this error, check

  • Check the spelling and capital letters of the name in the import line.
  • Use from module import name for functions and classes inside a module.
  • For a third-party library, use its import name: you install pillow but write import PIL, and install scikit-learn but write import 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 install first.

All Python errors · How to read a traceback · Step through your code