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.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'

最佳答案

就我而言,结果是 pyOpenSSL 的版本太旧了。我的 Ubuntu 14.4 运行的是 pyOpenSSL 0.13 版。我在使用 elasticsearch python 库时收到报告的错误。

我必须通过运行来更新 pyOpenSSL:

sudo pip install -U pyOpenSSL

您可以使用以下命令检查 pyOpenSSL 版本:
python -c 'import OpenSSL; print(OpenSSL.__version__)'

关于Python 请求和流媒体 - AttributeError : 'X509' object has no attribute '_x509' ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40628315/

10-13 08:19