無論是Anaconda vs Miniconda vs Miniforge 中的哪個,只要使用conda就涉及源,換源的目的是為了加速包的獲取
修改配置文件
通過修改用戶目錄下的 .condarc
文件來使用
不同系統下的 .condarc
目錄如下:
- Linux:
${HOME}/.condarc
- macOS:
${HOME}/.condarc
- Windows:
C:\Users\<YourUserName>\.condarc
注:
- Windows 用戶無法直接創建名為
.condarc
的文件,可先執行conda config --set show_channel_urls yes
生成該文件之后再修改。 - 由于更新過快難以同步,TUNA 等鏡像站不同步
pytorch-nightly
,pytorch-nightly-cpu
,ignite-nightly
這三個包。 - 如果您正在從某一鏡像源切換到另一鏡像源,請檢查鏡像源是否同步了您所需要的 repo,以及該 repo 是否支持您使用的平臺 (e.g. linux-64)。
- 為了保證以下配置在所有鏡像站可用,配置中只加入了少量必須的第三方源,
清華大學開源軟件鏡像站
channels:- defaults
show_channel_urls: true
default_channels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
即可添加 Anaconda Python 免費倉庫。
使用下列命令清除索引緩存,并安裝常用包測試一下。
conda clean -i
conda create -n myenv numpy
使用命令
查看源
conda config --show-sources###
C:\Users\johnny>conda config --show-sources
==> C:\johnny\soft\miniforge3\.condarc <==
channels:- conda-forge==> C:\Users\johnny\.condarc <==
channels:- defaults
custom_channels:conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
default_channels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
show_channel_urls: True
配置默認的源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
配置第三方源中
conda config --set custom_channels.conda-forge https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
其他鏡像站
https://help.mirrors.cernet.edu.cn/anaconda/
https://mirrors.ustc.edu.cn/help/anaconda.html
https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/