我一直在尝试通过python(2.7和3.5)做一个简单的授权请求,例如
import requests
requests.get('https://sub-domain.chargify.com/subscriptions.json', auth=('my-authorization-key', 'x'))
我收到以下错误
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='sub-domain.chargify.com', port=443): Max retries exceeded with url: /subscriptions.json (Caused by <class 'socket.error'>: [Errno 54] Connection reset by peer)
但如果我做一个 curl 调用,一切正常
curl -u my-authorization-key:x https://sub-domain.chargify.com/subscriptions.json
我什至尝试使用 urllib2 路由获得与请求类似的响应。请一位朋友在他的计算机上为我运行请求代码,效果很好。唯一的区别是他使用的是更新版本的请求,所以我将我的更新到他的版本不起作用。去了服务器并尝试了与上述完全相同的步骤,一切正常,仅在我的 mac 中使用请求没有错误。我已经在我的机器上更新了 python 2.7 和 3.6,认为这可能是原因但仍然有相同的结果
关于它可能是什么的任何想法?
从请求依赖项:pyOpenSSL,支持的 OpenSSL 版本为 1.0.1 1.0.2 1.1.0
检查 openssl 版本并更新,然后对其进行符号链接。
openssl version
brew update
brew install openssl
brew link --force openssl
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句