ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

随笔:urllib3.exceptions.SSLError: Can‘t connect to HTTPS URL because the SSL module is not available.

2021-04-06 16:32:37  阅读:1333  来源: 互联网

标签:available because python3.7 py SSL File line local python3


执笔墨飘烟2021/4/6urllib3.exceptions.SSLError处理方案

场景

刚配置的linux系统,安装完python3.7.9后使用requests模块,抛出异常:

Traceback (most recent call last):
  File "/usr/local/python3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 659, in urlopen
    conn = self._get_conn(timeout=pool_timeout)
  File "/usr/local/python3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 279, in _get_conn
    return conn or self._new_conn()
  File "/usr/local/python3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 948, in _new_conn
    "Can't connect to HTTPS URL because the SSL module is not available."
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/python3/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/python3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 727, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/usr/local/python3/lib/python3.7/site-packages/urllib3/util/retry.py", line 446, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ipservice.3g.163.com', port=443): Max retries exceeded with url: /ip (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 "test.py", line 6, in <module>
    rep = requests.get(url, verify=False)
  File "/usr/local/python3/lib/python3.7/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/python3/lib/python3.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/python3/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/python3/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/python3/lib/python3.7/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='ipservice.3g.163.com', port=443): Max retries exceeded with url: /ip (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

尝试方案

  1. 更新spacy(地址:https://blog.csdn.net/zcyzhangzhou/article/details/86572845):失败
  2. 更新openssl(地址:http://www.45fan.com/article.php?aid=19073158040128417480594681):失败
  3. 安装requests的依赖包(地址:https://www.cnblogs.com/hum0ro/p/9536033.html):失败

解决方案

因为python安装的时候可能没有安装openssl相关的开发包,因此需要手动安装:
yum install openssl-devel
安装好后重新编译一遍python或者删除重装

参考

https://docsxyz.com/wiki/python/ssl-module-is-not-available

标签:available,because,python3.7,py,SSL,File,line,local,python3
来源: https://blog.csdn.net/qq_44985692/article/details/115463249

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有