In this article, we will learn how to solve or fix Modulenotfounderror: No Module Named Requests.
Also, in Python programming language, the “ModuleNotFoundError: No module named ‘requests’ “ will appears.
Why does the error occur?
The no module named requests error occur because If we forgot to install the “requests module” before importing or installing it in the wrong environment.
How to solve the ModuleNotFoundError: No module named ‘requests’?
To fix the error we will use different ways.
Open your project root directory we need to install the module by typing this command:
In a virtual environment or using Python 2
We will use this command for installing in Python 2.
pip install requests
For python 3
We will use this command for installing in Python 3.
pip3 install requests
For getting permissions error
We will use this command for installing in getting permissions error.
sudo pip3 install requests
pip install requests –user
When you don’t have pip in your PATH environment variable
We will use this command for installing if you don’t have pip in your PATH environment variable.
python -m pip install requests
For python 3
We will use this command for installing in Python 3
python3 -m pip install requests
Using py alias in Windows
We will use this command for installing using py alias in Windows.
py -m pip install requests
For Ubuntu/Debian
We will use this command for installing for Ubuntu/Debian.
sudo apt-get install python3-requests
For CentOS
We will use this command for installing in CentOS.
sudo yum install python-requests
For Anacondas
We will use this command for installing in Anacondas.
conda install -c anaconda requests
For Jupyter Notebook
We will use this command for installing Jupyter Notebook.
!pip install requests
The Typical Reasons that the Error Appears
The “ModuleNotFoundError: No module named ‘requests’” appears for numerous reasons:
- There is no requests module installed in your system. To install it, type this command: pip install requests
- Installing the module in a various Python version than the one you’re currently using.
- Installing the module globally and it is not installed in your virtual environment.
- Executing the IDE which is not the correct version of Python.
- Naming your module requests.py to replace the official module
- Defining the requests variable as a shadow of the imported variable.
When the error will continue, look at your Python version and to insure you are installing the module using the correct version of python.
Type this command to know your python version:
python –version
After you type the command the output will be like this:

Check if the package is installed
We will check if the requests module is installed by executing the pip show requests command.
pip3 show requests
The pip show requests command whether the package which is not installed or it will show a lot of information about the module, along with the location where the package is installed.

Diagnostic checklist for “No module named ‘requests'”
- Verify pip install target. Run
pip show requests— if not installed, runpip install requests. - Check the active Python interpreter.
which python(mac/Linux) orwhere python(Windows). Both pip and python must point to the same environment. - Check virtual environment activation. If you use venv/conda, activate before installing:
source .venv/bin/activate. - Rule out uppercase/lowercase. Python imports are case-sensitive:
import PyPDF2notimport pypdf2. - Rule out the pip-vs-package-name mismatch. Some packages install under a different name than you import (e.g.
pip install beautifulsoup4→import bs4).
Installing requests — web scraping library
# Standard install pip install requests # For beautifulsoup4 pip install beautifulsoup4 # note: 4 in the name # For Selenium (needs browser driver) pip install selenium # Also install ChromeDriver or GeckoDriver
Common causes for missing scraping modules
- bs4 vs beautifulsoup4. Install as
pip install beautifulsoup4, import asfrom bs4 import BeautifulSoup. - Selenium browser driver missing. Selenium 4+ can auto-download via Selenium Manager. Older versions need manual ChromeDriver/GeckoDriver install.
- lxml missing. Some scrapers require lxml as a parser dependency:
pip install lxml. - requests vs httpx. Modern async scrapers use httpx or aiohttp — both need separate install.
Working code example
# Requests quick check
import requests
r = requests.get("https://httpbin.org/json")
print(r.status_code)
# BeautifulSoup quick check
from bs4 import BeautifulSoup
soup = BeautifulSoup("<p>hi</p>", "html.parser")
print(soup.text)
Best practices
- Respect robots.txt. Do not scrape sites that explicitly disallow it.
- Add rate limiting. Sleep between requests to avoid overwhelming target sites.
- Consider httpx over requests. httpx supports HTTP/2 and async. Requests is still perfect for simple use cases.
Official documentation
Frequently Asked Questions
What is Python ModuleNotFoundError and what causes it?
ModuleNotFoundError (a subclass of ImportError) is raised when Python cannot find the module you tried to import. Common causes: the package isn’t installed (pip install missing), wrong virtual environment activated, typo in module name, or Python can’t find your local module on the import path. The error message names exactly which module is missing.
How do I fix ‘ModuleNotFoundError: No module named X’?
Run pip install X first. If that succeeds but you still get the error, check which Python you’re using (which python OR python –version) vs which pip (which pip OR pip –version), they must match. Common gotcha: pip points to system Python 3.9 but you’re running python3.11 in a venv. Inside the venv, use python -m pip install X to be sure pip matches the active Python.
Why does my code work in one environment but not another?
Different Python versions or different installed packages. To diagnose: pip freeze > requirements.txt on the working environment, then pip install -r requirements.txt on the broken one. Use virtualenv (python -m venv venv) or conda for every project to avoid system-wide package collisions.
Is ModuleNotFoundError the same as ImportError?
ModuleNotFoundError is a subclass of ImportError added in Python 3.6. It specifically means ‘no such module exists.’ Plain ImportError covers a wider set: module exists but a name inside it can’t be imported (e.g. ‘cannot import name X from Y’). except ImportError catches both; except ModuleNotFoundError catches only the missing-module case.
Where can I find more ModuleNotFoundError fixes?
Browse the ModuleNotFoundError reference hub for 198+ specific module fixes (TensorFlow, Flask, Django, pandas, numpy, etc.). For related issues see ImportError. For broader Python setup see Python Tutorial hub.
Conclusion
To conclude, in this article we already learned how to fix or solve the Modulenotfounderror: No Module Named Requests.
Also, we already know how to install it in Windows, UBUNTU, CentOS, ANACONDAS, and JUPYTER NOTEBOOK.
