python - pip._vendor 奇怪的行为,但请求有效
问题描述
运行我的代码时遇到问题。我看到以下错误。有趣的是,当我将此代码带到其他环境(例如visual code
代码正在运行)并且我得到响应时...我认为自动添加的from pip._vendor import
请求有问题pycharm
。例如,visual code
正在添加imports requests
并且它可以工作。我应该怎么做这个代码才能正确运行pycharm
?
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed
to respond
During handling of the above exception, another exception occurred:
self, "Failed to establish a new connection: %s" % e
pip._vendor.urllib3.exceptions.NewConnectionError: <pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000217D0A2B9C8>: Failed to establish a new connection: [WinError 10060] A connection atte
mpt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
raise MaxRetryError(_pool, url, error or ResponseError(cause))
pip._vendor.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='xxx.xxx', port=443): Max retries exceeded with url: /api/ser (Caused by NewConnectionError('<pip._vend
or.urllib3.connection.HTTPSConnection object at 0x00000217D0A2B9C8>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respo
nd after a period of time, or established connection failed because connected host has failed to respond'))
这是我的代码:
from pip._vendor import requests
if __name__ == '__main__':
print(msg)
data = {
"Ex": 22
}
}
headers = {
"Authorization": "Bearer xxxx"
}
response = requests.post("https://xxx.xxx/api/ser", headers=headers, json=data)
print(response.json())
解决方案
您正在导入库的_vendor
导入pip
。它可以工作,但你可以这样做import requests
(如果它已经安装)。
推荐阅读
- wordpress - 链接共享显示带有我的 wordpress 网站名称的 javascript 代码
- artifactory - 工件的工件保留。詹金斯神器插件
- php - 更改日期格式 FacetWP
- java - java.text.ParseException:无法解析的日期:“2018 年 10 月 29 日 00:01”
- configuration - 在 Visual Studio 2017 中构建 Wix wxs 文件时出现问题
- swift - Swift:Simple DispatchQueue 无法正确运行和通知
- java - 重复 Jubula 测试用例中的 LAST 操作
- python - 如何在不增加内存消耗的情况下就地修改数组/列表的 python 字典?
- sql - Select rows that do not have the opposite value in another row
- java - 尝试将 spring-war 部署到 websphere 时出现 Unmarshalling 错误消息?