An error is reported when a website requests HTTPS using the requests module in Python

Alibaba cloud Q & A 2022-02-13 07:33:10 阅读数:439

error reported website requests https

The code is as follows

import requestsprint(requests.get("https://www.baidu.com"))

The error message is as follows , What causes

Traceback (most recent call last): File "/Users/jiangyd/python3_zy/lib/python3.6/site-packages/requests/adapters.py", line 440, in send timeout=timeout File "/Users/jiangyd/python3_zy/lib/python3.6/site-packages/urllib3/connectionpool.py", line 588, in urlopen conn = self._get_conn(timeout=pool_timeout) File "/Users/jiangyd/python3_zy/lib/python3.6/site-packages/urllib3/connectionpool.py", line 250, in _get_conn return conn or self._new_conn() File "/Users/jiangyd/python3_zy/lib/python3.6/site-packages/urllib3/connectionpool.py", line 821, in _new_conn raise SSLError("Can't connect to HTTPS URL because the SSL "urllib3.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.During handling of the above exception, another exception occurred:Traceback (most recent call last): File "/Users/jiangyd/PycharmProjects/untitled10/mm.py", line 12, in <module> print(requests.get("https://www.baidu.com")) File "/Users/jiangyd/python3_zy/lib/python3.6/site-packages/requests/api.py", line 72, in get return request('get', url, params=params, **kwargs) File "/Users/jiangyd/python3_zy/lib/python3.6/site-packages/requests/api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "/Users/jiangyd/python3_zy/lib/python3.6/site-packages/requests/sessions.py", line 502, in request resp = self.send(prep, **send_kwargs) File "/Users/jiangyd/python3_zy/lib/python3.6/site-packages/requests/sessions.py", line 612, in send r = adapter.send(request, **kwargs) File "/Users/jiangyd/python3_zy/lib/python3.6/site-packages/requests/adapters.py", line 514, in send raise SSLError(e, request=request)requests.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.



Take the answer 1:

Hello! , Please install ssl Related modules (Py3)

pip install pyopenssl

copyright:author[Alibaba cloud Q & A],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130733092128.html