ModuleNotFoundError

noun

say it: “MOJ-ool not FOWND ER-er” /ˈmɑdʒul nɑt ˈfaʊnd ˈɛrər/

The error Python stops with when code tries to import a module or package that isn't installed in the Python running it.

What does ModuleNotFoundError mean?

ModuleNotFoundError is the error Python gives when an import names a module or package it can't find. It most often means the package isn't installed in the Python that ran the code, such as a virtual environment that isn't turned on.

import pandas as pd
# ModuleNotFoundError: No module named 'pandas'
# pandas isn't installed in this Python: turn on .venv and run pip install -r requirements.txt

In a sentence

  • “Turning on the virtual environment made the ModuleNotFoundError go away.”
  • “The script stopped with ModuleNotFoundError because pandas wasn't installed in that environment.”

Level: Apprentice · More Python terms at this level

Updated