其他分享
首页 > 其他分享> > conda源管理

conda源管理

作者:互联网

第1步:

dell@dell-Precision-5820-Tower:~$ gedit ~/.condarc

第2步:

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/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
  - https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
  - https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
  - https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
ssl_verify: true
show_channel_urls: true
#changeps1: False

第3步:

save.

第4步:

dell@dell-Precision-5820-Tower:~$ conda update conda

出现下面的错误:

Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.ustc.edu.cn/anaconda/pkgs/free/linux-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.bfsu.edu.cn\', port=443): Max retries exceeded with url: /anaconda/pkgs/free/linux-64/repodata.json (Caused by SSLError(SSLError("bad handshake: Error([(\'SSL routines\', \'ssl3_get_server_certificate\', \'certificate verify failed\')])")))'))

解决方案:

在我查阅了多篇博客,尝试了多种方案之后,终于找到两种解决方案(https://blog.csdn.net/kxqt233/article/details/121167753):

在命令行中输入conda config --set ssl_verify false修改设置,或者在文件~/.condarc末尾添加一行ssl_verify: false(有则修改即可)
将https改成http
两种方法选一种即可

原因分析
https协议比http协议多了SSL,TLS等验证和加密的阶段,可能是在与清华源进行SSL验证的过程中会出问题,因此需要关掉SSL验证,或者改用http协议。但是使用SSL验证是有助于保障传输过程的可靠性的。
显示现有的源:

conda config --show channels

 又出现如下的问题:

Solving environment: failed

CondaValueError: Malformed version string '~': invalid character(s).

解决方案(https://stackoverflow.com/questions/56084960/condavalueerror-malformed-version-string-invalid-characters):

I needed to remove conda-forge from my .condarc file. Then everything worked fine.

现在的.condarc文件是:

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.ustc.edu.cn/anaconda/pkgs/main/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
  - https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
  - https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
ssl_verify: false
show_channel_urls: true

conda设置默认源:

最近由于某些因素清华的conda镜像登不上去了,所以需要换回conda的默认源。查看了conda config的文档后,发现直接删除channels即可。命令如下:

conda config --remove-key channels

Anaconda的默认源:

https://repo.anaconda.com/pkgs/main
https://repo.anaconda.com/pkgs/r
https://repo.anaconda.com/pkgs/msys2

用法:

conda config --add channels https://repo.anaconda.com/pkgs/main
conda config --add channels https://repo.anaconda.com/pkgs/r
conda config --add channels https://repo.anaconda.com/pkgs/msys2
conda config --set show_channel_urls yes

 




 

标签:cn,管理,anaconda,conda,pkgs,https,edu
来源: https://www.cnblogs.com/yibeimingyue/p/16592084.html