python3.7、python3.8安装, 解决pip is configured with locations that require TLS/SSL问题

Python3.7和3.8安装时遇到pip TLS/SSL配置问题,主要原因是openssl版本过低。参考链接中的教程,针对Python3.7和3.8的用户,该问题已成功解决。

问题:

[root@localhost bin]# pip3 install mysqll
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting mysqll
  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/mysqll/
  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/mysqll/
  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/mysqll/
  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 av
### 修复pip在Windows系统上的TLS/SSL配置错误 当在Windows系统上使用pip时,如果出现“pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available”这样的错误信息,通常是因为PythonSSL模块不可用或未正确安装。以下是解决问题的详细方法: #### 1. 检查Python是否正确安装 确保Python是在启用SSL支持的情况下编译和安装的。可以通过以下命令检查Python是否支持SSL: ```python import ssl print(ssl.OPENSSL_VERSION) ``` 如果上述代码运行成功并输出OpenSSL版本,则说明Python已正确安装并支持SSL[^1]。 #### 2. 重新安装Python 如果Python不支持SSL,可能需要重新安装Python。下载最新版本的Python安装程序,并在安装过程中勾选“Add Python to PATH”选项,同时确保安装了所有必要的组件(如OpenSSL库)。可以从官方站点获取最新的Python安装包[^3]。 #### 3. 配置环境变量 有时,即使安装了正确的Python版本,系统仍无法找到OpenSSL的动态链接库(DLL)。可以尝试将Python的`DLLs`目录添加到系统的环境变量中。例如,如果Python安装在`C:\Python39`,则需将`C:\Python39\DLLs`添加到`PATH`环境变量中[^5]。 #### 4. 使用--trusted-host参数绕过SSL验证 如果暂时无法解决SSL问题,可以使用`--trusted-host`参数跳过SSL验证。例如: ```bash pip install some-package --trusted-host pypi.org --trusted-host files.pythonhosted.org ``` 这种方法虽然可以解决问题,但并不推荐,因为它会使连接变得不安全[^4]。 #### 5. 更新pip和setuptools 确保pip和setuptools是最新版本。可以通过以下命令更新它们: ```bash python -m pip install --upgrade pip setuptools ``` 这一步可以避免由于旧版本pip导致的兼容性问题[^2]。 #### 6. 修改pip配置文件 如果需要长期忽略SSL验证,可以在pip配置文件中设置相关参数。对于Windows系统,配置文件位于`%APPDATA%\pip\pip.ini`,添加以下内容: ```ini [global] trusted-host = pypi.org files.pythonhosted.org ``` ### 注意事项 - 如果使用的是Anaconda发行版,可能需要检查Anaconda安装路径中的OpenSSL DLL文件是否与系统其他位置的DLL冲突[^5]。 - 确保系统已安装最新版本的Visual C++ Redistributable,因为某些DLL依赖于此[^3]。
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值