小编num*_*oth的帖子

无法使用网址请求

我只是编写了以下代码来使用Requests库

requests tests
import requests
r = requests.get('https://api.github.com/events')
Run Code Online (Sandbox Code Playgroud)

但即使我使用,我仍然会收到相同的错误消息 from requests import *

Traceback (most recent call last):
File "/Users/dvanderknaap/Desktop/Organized/CS/My_Python_Programs/requests.py", line 3, in <module>
import requests
File "/Users/dvanderknaap/Desktop/Organized/CS/My_Python_Programs/requests.py", line 5, in <module>
r = requests.get('https://api.github.com/events')
AttributeError: 'module' object has no attribute 'get'
Run Code Online (Sandbox Code Playgroud)

我尝试使用重新安装请求pip install requests,但输出是:

Requirement already satisfied (use --upgrade to upgrade): requests in /anaconda/lib/python3.5/site-packages
Run Code Online (Sandbox Code Playgroud)

我认为问题是它安装在我的python3.5库中,但我使用的是python2.7,但我不知道如何解决这个问题.建议吗?

python python-requests anaconda

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

anaconda ×1

python ×1

python-requests ×1