Python请求和流式处理-AttributeError:';X509和x27;对象没有属性'_x509和x27;
Python请求存在以下问题:Python请求和流式处理-AttributeError:';X509和x27;对象没有属性'_x509和x27;,python,python-requests,Python,Python Requests,Python请求存在以下问题: rs = requests.get(STREAM_URL, stream=True,headers=headers) Process Process-1: Traceback (most recent call last): File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap self.run() File "/usr/lib/python2.
rs = requests.get(STREAM_URL, stream=True,headers=headers)
Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "oanda_streaming_pairs_server.py", line 287, in multistreamer
rs = requests.get(STREAM_URL, stream=True,headers=headers)
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/adapters.py", line 423, in send
timeout=timeout
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
chunked=chunked)
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/packages/urllib3/connectionpool.py", line 350, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/packages/urllib3/connectionpool.py", line 835, in _validate_conn
conn.connect()
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/packages/urllib3/connection.py", line 330, in connect
cert = self.sock.getpeercert()
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/packages/urllib3/contrib/pyopenssl.py", line 324, in getpeercert
'subjectAltName': get_subj_alt_name(x509)
File "/usr/local/lib/python2.7/dist-packages/requests-2.12.0-py2.7.egg/requests/packages/urllib3/contrib/pyopenssl.py", line 166, in get_subj_alt_name
cert = _Certificate(openssl_backend, peer_cert._x509)
AttributeError: 'X509' object has no attribute '_x509'
这可能是新版本的bug。在我的例子中,原来pyOpenSSL的版本太旧了。我的Ubuntu 14.4运行的是pyOpenSSL的0.13版。我在elasticsearch python库中收到报告的错误 我必须通过运行以下命令来更新pyOpenSSL:
sudo pip install -U pyOpenSSL
您可以通过以下方式检查pyOpenSSL版本:
python -c 'import OpenSSL; print(OpenSSL.__version__)'
您至少需要PyOpenSSL版本0.14 这对我很有用,来自:
如果遇到AttributeError:“X509”对象没有属性“\u X509”错误,请将请求库的版本从2.12.1降级到2.11.1<代码>使用pip安装请求==2.11.1。请求问题:必须使用版本2.11.1才能工作。您找到原因了吗?我在ubnutu虚拟机上看到了这种行为,该虚拟机也有请求2.12.1。奇怪的是。我有另一个具有相同请求版本2.12.1的VM,在那里它工作正常!!没有。我只是检查了在其他服务器和本地开发人员上运行的版本。没有一个版本是最新的。我假设代码中存在缺陷或与某些依赖项的兼容性。看起来更像是兼容性问题。您是否有
/usr/lib
vs/usr/local/lib
?