gpt4 book ai didi

python-2.7 - 模块 chembl_webresource_client.new_client 失败,因为 python 2.7.9 下的 urllib3 中的 ssl 损坏

转载 作者:太空宇宙 更新时间:2023-11-03 14:11:14 27 4
gpt4 key购买 nike

pypi 提供的模块 chembl_webresource_client.new_client(版本 0.8.5)是一个 client for accessing the new web service API of the ChEMBL数据库。它使用 urllib3broken for a while在 python 2.7.9 中,由于内置 ssl 模块中缺少 sslwrap。如果我尝试导入模块:

from chembl_webresource_client.new_client import new_client

堆栈跟踪看起来像这样:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/chembl_webresource_client/new_client.py", line 63, in <module>
new_client = client_from_url(Settings.Instance().NEW_CLIENT_URL + '/spore')
File "/usr/lib/python2.7/site-packages/chembl_webresource_client/new_client.py", line 27, in client_from_url
res = requests.get(url)
File "/usr/lib/python2.7/site-packages/requests/api.py", line 65, in get
return request('get', url, **kwargs)
File "/usr/lib/python2.7/site-packages/requests/api.py", line 49, in request
response = session.request(method=method, url=url, **kwargs)
File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 461, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 370, in send
timeout=timeout
File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 341, in _make_request
self._validate_conn(conn)
File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 762, in _validate_conn
conn.connect()
File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/connection.py", line 238, in connect
ssl_version=resolved_ssl_version)
File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py", line 256, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python2.7/ssl.py", line 350, in wrap_socket
_context=self)
TypeError: __init__() got an unexpected keyword argument 'server_hostname'

最后我可以解决这个问题,我会在下面发布解决方案。

最佳答案

首先,我尝试使用来自 this thread 的补丁, 没有成功。最后来自this answer我发现,安装 pyopensslndg-httpsclientpyasn1 是解决问题所必需的。

pip2 install pyopenssl
pip2 install ndg-httpsclient
pip2 install pyasn1

并且可以导入ChEMBL模块:

from chembl_webresource_client.new_client import new_client

关于python-2.7 - 模块 chembl_webresource_client.new_client 失败,因为 python 2.7.9 下的 urllib3 中的 ssl 损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29916593/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com