方法一,安装openssl 最新版可彻底解决
可以直接下载新版的 openssl 安装,但建议用windows下的包管理器choco 安装,步骤如下:
- 确认已经安装有windows dotNet Framework 4.5+
例如安装 .NET Framework 4.8 的 Runtime库:
https://dotnet.microsoft.com/download/dotnet-framework/net48这里是引用
- 确认已安装有 windows powershell 5.1
微软官方安装网址:
https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/wmf/setup/install-configure?view=powershell-7.1
安装后CMD运行powershell.exe,然后 输入以下代码查看版本号。
$PSVersionTable.PSVersion
- 安装Win下包管理器 choco
推荐方法是利用 chocolatey 的安装脚本 https://chocolatey.org/install.ps1
管理员权限下运行 powershell.exe, 执行以下代码即可
Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
- choco 安装好了,就可以方便的直接安装常用工具,如安装 openssl
choco install openssl
一般安装openssl 后, pip 无法使用ssl协议的问题就可解决。
方法二,使用非https协议的源
如国内的源
http://pypi.douban.com/simple/ 豆瓣
http://mirrors.aliyun.com/pypi/simple/ 阿里
http://pypi.hustunique.com/simple/ 华中理工大学
http://pypi.sdutlinux.org/simple/ 山东理工大学
http://pypi.mirrors.ustc.edu.cn/simple/ 中国科学技术大学
使用示例:
- 如用豆瓣的源安装 百度的库 baidu-aip
pip install baidu-aip -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
- 如用豆瓣的源安装 拼音模块 pinyin
pip install pinyin -i http://pypi.douban.com/simple --trusted-host pypi.douban.com