无法解决SSL证书验证问题,求TensorFlow 1.12.0有效下载方法
解决TensorFlow 1.12.0安装SSL证书验证失败的替代方案
方案1:使用国内PyPI镜像源安装
国内镜像源可绕开SSL证书验证问题,同时提升下载速度,执行对应命令即可:
- CPU版本:
pip install tensorflow==1.12.0 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com - GPU版本:
pip install tensorflow-gpu==1.12.0 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
也可替换为阿里云、清华等其他国内镜像源,比如http://mirrors.aliyun.com/pypi/simple/。
方案2:手动下载whl文件本地安装
- 找到适配Python 3.5.4的TensorFlow 1.12.0 whl文件(需匹配你的操作系统和架构,如Windows amd64、Linux x86_64)
- 下载完成后,切换到文件所在目录,执行本地安装命令:
示例:Windows下GPU版本文件名通常为pip install tensorflow-1.12.0-cp35-cp35m-<系统架构>.whltensorflow_gpu-1.12.0-cp35-cp35m-win_amd64.whl
方案3:临时关闭pip的SSL验证
直接跳过SSL证书验证环节,适合临时解决问题(注意:此方法存在安全风险,仅在可信环境下使用):
- CPU版本:
pip install tensorflow==1.12.0 --trusted-host pypi.org --trusted-host files.pythonhosted.org --no-verify-ssl - GPU版本:
pip install tensorflow-gpu==1.12.0 --trusted-host pypi.org --trusted-host files.pythonhosted.org --no-verify-ssl
方案4:更新系统SSL证书
若问题源于系统根证书过期,可尝试更新系统证书:
- Windows:安装微软官方提供的最新根证书包
- Debian/Ubuntu系Linux:
sudo apt-get update && sudo apt-get install ca-certificates - CentOS/RHEL系Linux:
sudo yum update ca-certificates
内容的提问来源于stack exchange,提问作者Pratima Prajapati
相关产品推荐
相关产品推荐

