简体   繁体   中英

I am using REST apis with Python. I am getting the a SSL error

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\requests\adapters.py", line 370, in send
    timeout=timeout
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.p
y", line 533, in urlopen
    conn = self._get_conn(timeout=pool_timeout)
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.p
y", line 246, in _get_conn
    return conn or self._new_conn()
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.p
y", line 738, in _new_conn
    raise SSLError("Can't connect to HTTPS URL because the SSL "
requests.packages.urllib3.exceptions.SSLError: Can't connect to HTTPS URL becaus
e the SSL module is not available.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "hosts-print.py", line 19, in <module>
    host_count_response = requests.get(host_count_url, verify=False)
  File "C:\Python34\lib\site-packages\requests\api.py", line 69, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Python34\lib\site-packages\requests\api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "C:\Python34\lib\site-packages\requests\sessions.py", line 465, in reques
t
    resp = self.send(prep, **send_kwargs)
  File "C:\Python34\lib\site-packages\requests\sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python34\lib\site-packages\requests\adapters.py", line 431, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module
is not available.

My code used to work fine until I added a certificate to Google chrome. I reinstalled python and the requests library, but it the code ran only once. After that the same error repeats.

您需要手动指向.ca文件(添加verify = path_to_ca_file ),或者可以禁用ssl verify = false

卸载旧版本的Python,然后重新安装Python和库以及重新安装chrome(删除cookie,扩展名和插件后)解决了该问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM