使用anaconda的一些小问题-SSLError
报错场景
安装完anaconda后按照网上的教程去配置国内的anaconda镜像(清华的),当执行如下创建虚拟环境的命令时报错
conda create -n myenv numpy
报错内容
CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/win-64/repodata.json
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
SSLError(MaxRetryError('HTTPSConnectionPool(host=‘mirrors.tuna.tsinghua.edu.cn’, port=443): Max retries exceeded with url: /anaconda/pkgs/msys2/win-64/repodata.json (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘ssl3_get_server_certificate’, ‘certificate verify failed’)])”)))'))
原因分析
仔细观察下面这一堆会发现是连接mirrors.tuna.tsinghua.edu.cn时SSL验证失败的问题,应该就是镜像地址中用的是https协议的问题,因为https协议会使用SSL验证,可能会导致连接失败。
解决方法
把https换成http,跳过SSL验证
方法①:在cmd中执行
conda config --set ssl_verify false
方法②:直接去C:\Users\用户名.condarc文件中 追加一行配置
ssl_verify: false