DevFixes
HomePythonPackages and imports
PythonBeginnerMedium severity

ModuleNotFoundError: No module named 'requests'

Python cannot find the requests package in the interpreter environment that is running your code.

2-5 min Popularity 98/100 Verified 2026-07-21
Debug with AI

What does this error mean?

Python reached an import statement for `requests`, searched the active interpreter's package paths, and did not find an installed module with that name.

Why does this happen?

  • The requests package has not been installed.
  • The package was installed for a different Python interpreter.
  • Your virtual environment is not active.
  • The IDE is configured to use a different interpreter than your terminal.
  • A local file or folder is interfering with package resolution.

AI explanation

Plain-English analysis

Think of each Python environment as its own toolbox. Your code asked for the `requests` tool, but the toolbox attached to the running Python process does not contain it. Installing the package with that exact interpreter, or switching to the intended environment, resolves the mismatch.

Quick fix

Terminal
python -m pip install requests
python -c "import requests; print(requests.__version__)"
Expected output: A version number such as 2.32.5

Step-by-step fix

1Install requests with the active interpreterUsing `python -m pip` ties pip to the same Python executable that will run your application.88%
Command
python -m pip install requests
2Activate the project virtual environmentIf requests is already listed in your project dependencies, activate the environment before running the script.72%
Command
.venv\Scripts\activate
python -m pip install -r requirements.txt
3Select the correct IDE interpreterPoint VS Code, PyCharm, or your editor to the interpreter where requests is installed.49%

Alternative solutions

Windows

py -m pip install requests
py app.py

The Python launcher is often the most reliable command on Windows.

macOS / Linux

python3 -m pip install requests
python3 app.py

Use python3 when `python` is not mapped to Python 3.

Virtual environment

python -m venv .venv
.venv\Scripts\activate
python -m pip install requests

On macOS or Linux, activate with `source .venv/bin/activate`.

Conda

conda install requests
conda run python app.py

Install into the currently selected Conda environment.

Docker

RUN python -m pip install --no-cache-dir requests

Add the dependency to the image, then rebuild it.

Real example

Broken
python
import requests

response = requests.get("https://api.example.com")
Corrected
python
# requirements.txt
requests==2.32.5

# app.py
import requests

response = requests.get("https://api.example.com", timeout=10)

Frequently asked questions

The terminals are probably using different Python interpreters or virtual environments. Compare the output of `python -c "import sys; print(sys.executable)"` in both.

References