问题描述
在Visual Studio 2019 下Python安装第三方库,遇到问ssl证书问题。在安装matplotlib这个库时,出现以下问题。
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/matplotlib/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/matplotlib/ (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong versio
ERROR: Could not find a version that satisfies the requirement matplotlib (from versions: none)
ERROR: No matching distribution found for matplotlib
意思是在使用清华大学的镜像https://pypi.tuna.tsinghua.edu.cn/simple时不能连接上,也遇到ssl问题。
解决方法
换成阿里云的连接http://mirrors.aliyun.com/pypi/simple/,并且把连接设置为信任。
具体步骤
一 本地文件设置
在C盘—用户—账户名----pip文件夹(如果没有新建一个)
在pip文件下,新建一个“pip.ini”文件
然后用记事本打开,把下面内容复制进去保存。
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
二,VS2019上的配置
找到 “解决方案资源管理器”,右击 “Python环境”,点击 “查看所有Python环境”
找到 “概述”,并点击 “PowerShell中打开”
输入
pip config list
得到如下界面:
下面我就可以之间使用,pip install pandas等命令安装第三方库了