问题描述
前段时间运行pip3 install numpy
时, 遇到如下异常.
localhost:bin sean$ pip3 install numpy --trusted-host pypi.douban.com
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
Could not fetch URL https://pypi.org/simple/numpy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/numpy/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
ERROR: No matching distribution found for numpy
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
解决措施
根据描述. 猜测有2种情况:
- 检查OpenSSL是否安装好. (使用
openssl version
进行查看)
localhost:bin sean$ openssl version
LibreSSL 2.6.5
mac安装openssl
可以选择编译安装. 或者brew install openssl
.
- python ssl 功能没有安装好
localhost:HoshinoBot sean$ python3
Python 3.8.6 (v3.8.6:db455296be, Sep 23 2020, 13:31:39)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>>
# 如果错误这边是会有报错的。
- 使用代理和信任地址
个人使用后.并没有成效.
- 重装python(有效)
之前是使用编译安装. 最后实在没有办法.选择了使用dmg
进行安装. 问题解决.
localhost:HoshinoBot sean$ pip3 install -r requirements.txt
Collecting nonebot[scheduler]~=1.6.0
Using cached nonebot-1.6.0.tar.gz (24 kB)
Requirement already satisfied: aiocqhttp>=1.2 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from -r requirements.txt (line 2)) (1.3.0)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/lxml/
Collecting lxml>=4.4.1
Downloading lxml-4.6.1-cp38-cp38-macosx_10_9_x86_64.whl (4.6 MB)
|████████████████████████████████| 4.6 MB 15 kB/s
Requirement already satisfied: pytz>=2019.3 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from -r requirements.txt (line 4)) (2020.4)
Requirement already satisfied: requests>=2.22.0 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from -r requirements.txt (line 5)) (2.24.0)
Collecting sogou_tr_free>=0.0.6
Others
-
stackoverflow
https://stackoverflow.com/questions/41328451/ssl-module-in-python-is-not-available-when-installing-package-with-pip3 -
使用代理或者信任地址
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org 包名
Pycharm 用pip命令安装第三方包出现retrying且ssl error问题汇总
-
重新安装python
python3.7安装后ssl问题 -
临时
Python3 ssl模块不可用的问题
python pip 安装失败 Could not find a version that satisfies the requirement APScheduler -
修改python编译文件重新编译
https://blog.csdn.net/qq_38231051/article/details/87600814
一些尝试过程中的命令
pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --user
pip3 install -r requirements.txt xlrd -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
--trusted-host pypi.org --trusted-host files.pythonhosted.org
pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.org --trusted-host files.pythonhosted.org
pip3 install aiohttp>=3.6.1 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com