Python 3.11.5 pip遇SSL模块缺失,求环境变量解决方案
解决Python pip SSL模块不可用的环境变量调整方案
问题重现
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 WARNING: There was an error checking the latest version of pip.
环境变量问题分析
你的Path环境变量存在三个核心问题:
- 大量重复的路径条目,易引发版本冲突
- Python 3.11路径与WindowsApps路径拼接错误(
C:\Users\Admin\AppData\Local\Programs\Python\Python311%USERPROFILE%\AppData\Local\Microsoft\WindowsApps) - 官方Python与Anaconda路径混杂,未明确调用优先级
环境变量调整步骤
- 清理重复条目:删除所有重复出现的路径(如重复的Anaconda、Python 3.11、VS Code相关路径),仅保留一份。
- 修复路径拼接错误:将错误的拼接路径拆分为两个独立路径,添加到Path中:
C:\Users\Admin\AppData\Local\Programs\Python\Python311%USERPROFILE%\AppData\Local\Microsoft\WindowsApps
- 添加SSL依赖路径:若使用官方Python 3.11,将
C:\Users\Admin\AppData\Local\Programs\Python\Python311\DLLs加入Path,该目录包含SSL所需的动态链接库。 - 调整路径优先级:
- 若优先使用官方Python 3.11,将以下路径移至Path最顶部:
C:\Users\Admin\AppData\Local\Programs\Python\Python311、C:\Users\Admin\AppData\Local\Programs\Python\Python311\Scripts - 若优先使用Anaconda,将以下路径移至Path最顶部:
C:\Users\Admin\anaconda3、C:\Users\Admin\anaconda3\Scripts、C:\Users\Admin\anaconda3\Library\bin
- 若优先使用官方Python 3.11,将以下路径移至Path最顶部:
- 验证修复效果:关闭所有命令行窗口后重新打开,执行
python --version确认当前使用的Python版本,再运行pip install --upgrade pip测试是否解决SSL错误。
内容的提问来源于stack exchange,提问作者Guillaume Crasson
相关产品推荐
相关产品推荐

