pypi 提供的模块chembl_webresource_client.new_client
(版本 0.8.5)是用于访问 ChEMBL数据库的新 Web 服务 API 的客户端。它使用在 python 2.7.9urllib3
中被破坏了一段时间sslwrap
,因为内置ssl
模块中缺少。如果我尝试导入模块:
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'
最后我可以解决这个问题,我将在下面发布解决方案。