windows: pip install 报错SSLError Can‘t connect to HTTPS URL because the SSL module is not available

最新推荐文章于 2025-06-11 09:01:11 发布
本文解决了一个常见的pip安装时报错问题,即由于SSL模块不可用导致无法连接HTTPS的问题。通过更换源的方式成功安装了opencv-python,并提供了临时测试源及Windows命令行永久更换源的方法。 摘要生成于 ,由 DeepSeek-R1 满血版支持,
  • windows
  • anaconda
  • pip清华源

通过pip install 安装不成功,会报错(Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

错误详情如下:

ghua.edu.cn', port=443): Max retries exceeded with url: /simple/opencv-python/ (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 opencv-python (from versions: none)                                                                     
ERROR: No matching distribution found for opencv-python                                                                                                                
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.tuna.tsinghua.edu.cn/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.c
.cn', 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    ERROR: Could not find a version that satisfies the requirement opencv-python (from versions: none)
ERROR: No matching distribution found for opencv-python
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.tuna.tsinghua.edu.cn/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.c
n', 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        
WARNING: There was an error checking the latest version of pip.

具体是什么错误什么原因导致,不去深究了。或许是源本身有问题?下面直接提供解决方法,通过更换源解决了该错误

临时源测试

pip install opencv-python -i http://pypi.douban.com/simple
# 依然会报以下错误,提示 is not a trusted
Looking in indexes: http://pypi.douban.com/simple
WARNING: The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use H
TTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host pypi.douban.com'.
ERROR: Could not find a version that satisfies the requirement opencv-python (from versions: none)
ERROR: No matching distribution found for opencv-python
WARNING: The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use H
TTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host pypi.douban.com'.
WARNING: There was an error checking the latest version of pip.

加上--trusted-host,命令如下不会报错了

pip install opencv-python -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

windows命令行更换源(永久)

有很多人是用手动方式,在C:\Users\Administrator\AppData\Roaming下,创建一个pip文件夹,编辑pip.ini文件
这里采用命令操作,win+R然后cmd的命令行换源,输入以下两行指令即可

# 以阿里云为例
pip config set global.index-url http://mirrors.aliyun.com/simple
pip config set global.trusted-host mirrors.aliyun.com
# 还有其他很多源,比如以下:
# http://mirrors.aliyun.com/pypi/simple 阿里云
# http://pypi.douban.com/simple 豆瓣
# https://pypi.tuna.tsinghua.edu.cn/simple 清华大学
# http://pypi.mirrors.ustc.edu.cn/simple 中国科学技术大学
					
Python3 Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available)解决方式
Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available)
之前被一个问题困扰了很久,因为装的anaconda环境无法安装任何东西,另外正好处于官方源没有给国内授权,所以当我换主机安装anaconda环境时,出现了一个意想不到的问题,另外拜一些csdn帖所赐,整了一个下午,因为网络很差,没有想过重装,但其实重装选对了选项就是一分钟的事情。 Caused by SSLError("Can’t connect to HTTPS URL because ... pip install numpy 时报异常: SSLError("Can\'t connect to HTTPS URL because the SSL module is not available. 我用的minicaonda,之前安装的,重装系统后,miniconda还能继续用。 就是添加三条环境变量: D:\Anaconda3; D:\Anaconda3\Scripts; D:\Anaconda3\Library\bin 方案2:安装openss... 本文描述手动编译 python3.10 缺少 openssl 模块问题解决方案和几个小时解决这个问题的全过程。虽然我编译的是 python3.10,但是对于 python3.6、python3.8 应该同样适用。 给新手说一下,我的服务器环境是 centos7,你们如果是其他环境,不要奇怪为啥某些命令用不了,百度一下。下面进入正题: 安装 openssl-1.1.1 wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz --no
Caused by SSLError("Can’t connect to HTTPS URL because the SSL module is not available) 原因是anaconda没有安装好,环境变量没有配置成功,需要添加三条环境变量 E:\anaconda; E:\anaconda\Scripts; E:\anaconda\Library\bin
文章目录成功解决win10下 Can't connect to HTTPS URL because the SSL module is not available问题描述解决方案把D:\ANACONDA\Library\bin加入系统环境变量(请参考你自己的安装路径) 成功解决win10下 Can’t connect to HTTPS URL because the SSL module is not available ​ 在安装pyinstaller的时候,提示无法连接HTTPSSSL
该问题是由于openssl版本与当前python需要的openssl版本不匹配造成的,可手动编译openssl,然后依赖于新的openssl,重新编译、安装python即可,具体操作步骤如下: 1.下载OpenSSL源码包: wget http://www.openssl.org/source/openssl-1.0.2j.tar.gz 2. 解压缩,编译安装: tar -zxvf openssl-1.0.2j.tar.gz cd openssl-1.0.2j ./config --prefi.
使用requests.get('https://www.balabala.com')报错SSLError("Can\'t connect to HTTPS URL because the SSL module is not available. 错误原因: 安装Python的时,未把ssl模块编译进去。 解决方案: 重新编译安装python,并编译ssl。 具体步骤 : 1、安装SSL wget http://www.openssl.org/source/openssl-1.0.2...