Requests module installed by the pip it works fine not get anything error. If you try to import Requests without installing the module using pip, then you will face ImportError: No module named requests, this error.
In this article, we will discuss about this ImportError: No module named requests error in Python. And how to resolve the error all the possible solutions with examples.
How ImportError: No module named requests Error Occurs?
Most of the time you get this error while import Requests without installing the module using pip, looks like the below:
ImportError: No module named requests
How to fix ImportError: No module named requests Error?
There are different ways to fix ImportError: No module named requests this error. Let us take a look at every solution.
Install Requests in OSX/Linux
Install the requests module is using pip or pip3 for Python3. if you have already installed pip.
For Python 2
sudo pip install requests
For Python 3
sudo pip3 install requests
Alternatively, if you have easy_install in your project file. You can install requests using by this command:
Using easy install
sudo easy_install -U requests
For CentOs
sudo yum install python-requests
For Ubuntu
To install the requests module on Debian/Ubuntu for Python2:
sudo apt-get install python-requests
And to install the requests module on Debian/Ubuntu for Python3:
sudo apt-get install python3-requests
Install Requests in Windows
If you have pip
installed to the Path Environment Variable. you have to install the requests
module.
pip install requests
For python3
pip3 install requests
If you have not installed pip in your path, then you can run the command:
python -m pip install requests
For python3
python3 -m pip install requests
Now, I hope your error will be solved.
Conclusion
In this article, we have discussed what causes the error and we have discussed ways to fix the error.
we hope this article has been informative. Thank you for reading. Kindly comment and let us know if you found it helpful.