我在linux环境(RedHat 7.9 Maipo)中使用python 3.10.8。“手动安装python 3.10.8和所有库后,我遇到了以下错误:
> [root@epnm-lab ~]# python3
> Python 3.10.8 (main, Oct 14 2022, 02:15:05)
> [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux Type "help",
> "copyright", "credits" or "license" for more information.
> >>> import requests
> >>> username = "xxx"
> >>> password = "yyy"
> >>> ip = "zzz"
> >>> requests.get(f"https://{username}:{password}@{ip}/webacs/api/v4/data/Devices?.full=true",
> verify=False)
> Traceback (most recent call last): File
> "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py",
> line 692, in urlopen
> conn = self._get_conn(timeout=pool_timeout) File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py",
> line 281, in _get_conn
> return conn or self._new_conn() File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py",
> line 1011, in _new_conn
> raise SSLError( 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
> "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line
> 489, in send
> resp = conn.urlopen( File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py",
> line 787, in urlopen
> retries = retries.increment( File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line
> 592, in increment
> raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError:
> HTTPSConnectionPool(host='10.88.242.12', port=443): Max retries
> exces?.full=true (Caused by 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 "<stdin>", line 1, in
> <module> File
> "/usr/local/lib/python3.10/site-packages/requests/api.py", line 73, in
> get
> return request("get", url, params=params,**kwargs) File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in
> request
> return session.request(method=method, url=url,**kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line
> 587, in request
> resp = self.send(prep,**send_kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line
> 701, in send
> r = adapter.send(request,**kwargs) File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line
> 563, in send
> raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='10.88.242.12', port=443): Max retries
> exceedefull=true (Caused by SSLError("Can't connect to HTTPS URL
> because the SSL module is not available."))
> >>> [root@epnm-lab ~]#
我在这里的其他帖子中看到过,但没有找到解决方案。我也安装了openssl。
> [root@epnm-lab-02-ha-01 ~]# rpm -qa|grep ^openssl*
> openssl-1.0.2k-21.el7_9.x86_64
> openssl-libs-1.0.2k-21.el7_9.x86_64
这有什么问题吗?有人能帮我解决这个问题吗?
1条答案
按热度按时间okxuctiv1#
"解决了"
这个错误的解决方案是python 3.10版本使用openssl 1.1.1版本,而我的服务器使用openssl 1.0.2版本。python 3.10上的openssl 1.0.2版本已经被弃用。所以你需要安装python 3.9.x,因为这个版本支持openssl 1.0.2。
希望这对你有帮助!