随笔 - 1761  文章 - 0  评论 - 109  阅读 - 431万

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

 




 

posted on   一杯明月  阅读(1404)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2021-08-16 TensorFlow 调试器
2021-08-16 使用tf.print()打印tensor内容
2020-08-16 pointer-like classes, 关于智能指针
2020-08-16 non-explicite-one-argumen-constructor
2020-08-16 车道标线分割与分类
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示