← Go Back

How to Fix ModuleNotFoundError: No module named ...

ModuleNotFoundError is a Python exception that occurs when trying to import a module that is not installed. For example:

>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'requests'

We are trying to import the requests module, but it is not installed. The typical solution for this error is to install the module using pip. To do so, open a terminal and run:

python -m pip install requests

If the error persists, these are other possible causes:

  • The module you are trying to import is misspelled (for example, import request instead of import requests).

  • There are multiple versions of Python installed on your system, and the module is installed on a different version than the one running the code that is throwing the error.

  • The file you are trying to import is not located in the current working directory or in the Lib folder inside the Python installation directory.

pip modules packages


🐍 You might also find interesting: