[英]cannot import name requests python
Why is that when I run this script do I get the error "cannot import name requests" 为什么在运行此脚本时出现错误“无法导入名称请求”
I have already run "pip install requests" 我已经运行了“ pip安装请求”
from bzrlib import branch,requests, json
def x:
url = myURL
data = json.dumps({"one": "two"})
r = requests.post(url, data)
print r.json
You are trying to import bzrlib.requests
, not the top-level package requests
. 您正在尝试导入
bzrlib.requests
,而不是顶级包requests
。 The same applies to json
here. 同样适用于
json
。
Move the imports to separate lines : 将导入移动到单独的行 :
from bzrlib import branch
import requests
import json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.