0x01 问题
今天在win10下安装了一个Miniconda3,已经配置了清华的源,但是使用conda install命令安装库的时候仍然出现错误,错误信息如下。
1 2 3 4 5 6 |
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.continuum.io/pkgs/main/win-64/repodata.json.bz2> 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. ConnectTimeout(MaxRetryError("HTTPSConnectionPool(host='repo.continuum.io', port=443): Max retries exceeded with url: /pkgs/main/win-64/repodata.json.bz2 (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x00000247EB8CC1D0>, 'Connection to repo.continuum.io timed out. (connect timeout=9.15)'))",),) |
这个错误的大致意思的缺少ssl模块,网上很多解决方案都有问题,试了N种姿势都没有解决,后来结合谋篇文章的介绍解决了。
0x02 解决conda install的ssl错误
假设我现在要安装numpy库,下面的报错截图:
解决方案如下:
- 添加Miniconda的Library库目录到环境变量,目录如下:
1G:\Miniconda3_x64\Library\bin - 此时重新打开cmd安装尝试,如果还不行就执行下面的操作。
- 进入用户的根目录,我的是C:\Users\kTWO。
- 打开编辑.condarc文件。
- 删除下面这行:
1- default
我的.condarc内容如下:
1 2 3 4 5 6 7 8 9 |
channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ show_channel_urls: true |
0x03 解决pip install的ssl错误
- 在C:\Users\你的用户名\AppData\Roaming目录下创建pip文件夹。
- 在pip文件夹下创建pip.ini文件。
- 在pip.pip文件内写入下面的内容:
1 2 3 4 |
[global] timeout = 6000 index-url = http://pypi.douban.com/simple trusted-host = pypi.douban.com |