'Pip install modules not installing
I imported the module requests
within my project using:
pip install requests
Apparently the module implementation did not work.
This is the error:
File "scraping.py", line 1, in <module>
import requests
ImportError: No module named requests
Solution 1:[1]
Run pip install requests and the make sure run python3 file.py
Solution 2:[2]
Error explanation
This error basically says it can't find the requests
module, which is a third party module for handling http requests. There are a few issues that could cause this, but likely it just didn't install properly when you tried to pip install requests
Solution
Depending on your OS you can call pip from your python installation directly through:
Windows
python -m pip install requests
MacOS/Linux
sudo python3 -m pip install requests
Solution 3:[3]
pip show <package name>
will give you information about a specific package.
Here is a link with more info on pip show:
more info on pip show from the offical pip documentation
you can also do:
pip list
in the command line to get a list of all the packages pip has installed.
Note: in WSL(Windows Subsystem for Linux) you may need to use pip.exe list
and
pip.exe show
instead.
Solution 4:[4]
I had a similar problem a while ago where I installed the module with pip and got the same error. I used Pycharm IDE and had to go into settings -> project settings -> project interpreter and installed the module from there, which made it work. Might be similar in your IDE.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | diego |
Solution 2 | |
Solution 3 | Matthew_O |
Solution 4 | ThreeThreeZeroOne |