python如何导入requests模块,如何在Python中导入REQUESTS模块

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 "", line 1, in

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

>>>

解决方案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 \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)

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!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值