close

[Solved] ModuleNotFoundError: No module named ‘requests’

Today I am trying to use the requests package in my python app But I am facing the following error: ModuleNotFoundError: No module named ‘requests’ in Python. In this Exerror article, We are going to learn about How to reproduce this error and we will discuss All Possible Solutions Let’s Get Start With This Article.

How ModuleNotFoundError: No module named ‘requests’ Error Occurs?

I am trying to use the requests package in my python app But I am facing the following error.

ModuleNotFoundError: No module named 'requests'

So here I am writing all the possible solutions that I have tried to resolve this error.

How To Solve ModuleNotFoundError: No module named ‘requests’ Error?

  1. How To Solve ModuleNotFoundError: No module named ‘requests’ Error?

    To Solve ModuleNotFoundError: No module named ‘requests’ Error Sometimes You have installed python for different versions Just like You are using Python3 and You have installed a request for Python2 then you will face a module not found error. So First of all check which version of python are you using. Just run this command: python –version. Now, You know You are using Python 3.10 then you can install the request package for Python 3.10 By just running this command: pip3.10 install requests And now, You can use requests without any error. Thank You.

  2. ModuleNotFoundError: No module named ‘requests’

    ModuleNotFoundError: No module named ‘requests’ Error Occurs whenever you don’t have the Request package installed so You just need to install the request package and then your error will be solved. First of all open your terminal and just run the following. If You are using Python 2 then run this command: pip install requests And then you can import it and you can use it without facing any error. Thank you.

Solution 1: Install the Request package 

ModuleNotFoundError: No module named ‘requests’ Error Occurs whenever you don’t have the Request package installed so You just need to install the request package and then your error will be solved.

First of all open your terminal and just run the following. If You are using Python 2 then run this command.

pip install requests

And If you are using python3 then run the following command.

pip3 install requests

You don’t have pip in the Path variable then you can run this command.

python -m pip install requests

And if you are using python3 and your Pip is not settled into the path variable then run this command.

python3 -m pip install requests

And then you can import it and you can use it without facing any error. Just like this.

import requests

res = requests.get('your_url_here')
print(res)

Thanks.

Solution 2: Package is Installed for different Version

Sometimes You have installed python for different versions Just like You are using Python3 and You have installed a request for Python2 then you will face a module not found error. So First of all check which version of python are you using. Just run this command.

python --version

And Your Output will be something like this.

C:\Users\ssc>python --version
Python 3.10.4

Now, You know You are using Python 3.10 then you can install the request package for Python 3.10 By just running this command.

pip3.10 install requests

And now, You can use requests without any error. Thank You.

Solution 3: Install For Virtual Env

If you are using a virtual environment then You need to install the request package for your particular virtual env. First of all You can create new virtual env if you don’t have.

python3 -m venv venv

Then activate it by running this command.

source venv/bin/activate  # macOS
venv\Scripts\activate.bat # Windows

and then You can install requests in this environment.

pip install requests

Now, Your error must be solved. Thanks.

Solution 4: Select Python interpreter

Make Sure You are using the Right Python interpreter If You are using VS Code then Press CTRL + Shift + P OR Command + Shift + P to Open the command palette. And then type Python select interpreter and then select Desire version of Python and your error will be solved. Thank you.

Solution 5: Check requests is Installed or Not

If You are still facing an error then First of all check request module is actually installed or not. Just run this command in your terminal.

pip3 show requests

OR

python3 -m pip show requests

By running pip3 show requests command it will show you package is installed or not. If you don’t have requests installed then run this command.

pip3 install requests

OR 

python3 -m pip install requests

Now, Your error will be solved. Thank You.

Solution 6: Reinstall Package

First of all Just uninstall requests by running this command.

pip3 uninstall requests

OR

python3 -m pip uninstall requests

and then run this command to install the package.

pip3 install requests

OR

python3 -m pip install requests

and Now, Your error must be solved. Thanks.

Conclusion

It’s all About this error. I hope We Have solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Leave a Comment