Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Wish to learn webscrapping. I tried to import requests module in python but it throws an error as below.
>>> import requests
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import requests
ImportError: No module named 'requests'
>>>

I am using windows 7. Python 3.5.1.[64 bit]. If requests module is to be installed, then please direct me how? pip install requests throws an error as below.
>>> pip install requests
SyntaxError: invalid syntax
>>>
Posted
Updated 8-Mar-21 12:55pm
v2
Comments
Richard MacCutchan 9-Jan-16 5:25am    
You need to show the commands that cause the error. We cannot see your screen, and it is impossible to guess what you are doing.
Sandeep-ATOS 10-Jan-16 6:54am    
I've copy pasted the commands and its error message. Thanks!
Richard MacCutchan 10-Jan-16 8:30am    
Try
python -m pip install -h
to see the correct syntax for pip copmmands.
Sadhvik 3-Jul-17 6:06am    
plss help me...i am not getting it..can i have ur phone no. so that i can contact u?
my screen shows....
Traceback (most recent call last):
File "example.py", line 12, in <module>
from instabot import InstaBot
File "C:\Users\Prudhvik\Desktop\instabot.py-master\src\instabot.py", line 16, in <module>
import requests
ModuleNotFoundError: No module named 'requests'

You have to install the requests module. pip is the easiest option, but that is not a Python command. pip is an executable which you can find in <Python installation directory>\Scripts. So to install requests, open Windows's Command Prompt (so not Python) and run:
C:\Python35\Scripts\pip install requests

(assuming C:\Python35 is the Python installation directory)
 
Share this answer
 
Comments
Sandeep-ATOS 10-Jan-16 10:18am    
Thanks a lot. requests has been installed.
Thomas Daniels 10-Jan-16 10:19am    
You're welcome!
Member 13614398 9-Jan-18 10:45am    
I run into the following problem:
pip install requests
Collecting requests
Could not fetch URL https://pypi.python.org/simple/requests/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_ACCESS_DENIED] tlsv1 alert access denied (_ssl.c:777) - skipping
Could not find a version that satisfies the requirement requests (from versions: )
No matching distribution found for requests


Any Idea how to get a secure SSL connection with pip or how to circumvent SSL signin
Thomas Daniels 9-Jan-18 12:33pm    
I don't just know that; I suggest Googling the error message.
Yes, this is an old question, when I followed the commands above (THANK YOU) it helped me to realize that I was still missing something (lxml). Therefore, you will need to install both packages; "lxml" and "requests" using "pip install lxml" and "pip install requests".

1. First Find the directory where Python installed.
Let's say
"C:\Program Files (x86)\Python36_64\Scripts\"

2. Make sure you open CMD "Run as Admin", and run the following commands:

3. Change the directory to Python folder:
cd "C:\Program Files (x86)\Python36_64\Scripts\"
"pip install lxml" 
"pip install requests"


Hope this helps who else stumbled on this, just like me!
 
Share this answer
 
v3
Comments
Dave Kreskowiak 23-Dec-17 16:40pm    
You're only TWO YEARS too late answering a question that already answered way back then.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900