Conda國(guó)內(nèi)鏡像源及配置過(guò)程
一、Conda國(guó)內(nèi)鏡像源
# 清華大學(xué) 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/msys2/ # 中國(guó)科學(xué)技術(shù)大學(xué) 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.ustc.edu.cn/anaconda/cloud/msys2/ # 北京外國(guó)語(yǔ)大學(xué) https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/ https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/ https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/ # 南京大學(xué) https://mirror.nju.edu.cn/anaconda/pkgs/main/ https://mirror.nju.edu.cn/anaconda/pkgs/free/ # 華為云 https://mirrors.huaweicloud.com/anaconda/pkgs/main/ https://mirrors.huaweicloud.com/anaconda/pkgs/free/ https://mirrors.huaweicloud.com/anaconda/cloud/conda-forge/ # 騰訊云 https://mirrors.cloud.tencent.com/anaconda/pkgs/main/ https://mirrors.cloud.tencent.com/anaconda/pkgs/free/ https://mirrors.cloud.tencent.com/anaconda/cloud/conda-forge/ # 阿里 https://mirrors.aliyun.com/anaconda/pkgs/main/ https://mirrors.aliyun.com/anaconda/pkgs/free/ https://mirrors.aliyun.com/anaconda/cloud/conda-forge/ # 上海交通大學(xué) 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/
二、Conda臨時(shí)使用鏡像源
指定單個(gè)源
- 直接使用鏡像站URL
conda install -c https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/ package_name
- 或者使用鏡像源的別名
conda install -c conda-forge package_name
臨時(shí)指定多個(gè)源
- Conda按優(yōu)先級(jí)從左到右依次搜索
-c參數(shù)的源,最后搜索全局配置的源(~/.condarc 中的 channels)
conda install -c https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/ -c defaults package_name
創(chuàng)建環(huán)境時(shí)臨時(shí)指定源
conda create -n my_env -c https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/ python=3.9
避免搜索遠(yuǎn)程源
- 如果本地已有緩存包,強(qiáng)制使用本地包
conda install --use-local package_name
三、Conda永久配置鏡像源
通過(guò)conda命令配置
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ conda config --set show_channel_urls yes
直接修改.condarc文件
sudo vim ~/.condarc
- 在用戶(hù)目錄下創(chuàng)建或修改
.condarc文件
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/cloud msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
恢復(fù)默認(rèn)配置
- 刪除 ~/.condarc 文件(簡(jiǎn)單粗暴)
rm ~/.condarc
- 或者手動(dòng)移除 channels
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
四、倉(cāng)庫(kù)說(shuō)明
main、free和conda-forge是不同的軟件包倉(cāng)庫(kù),它們提供不同類(lèi)型的Python包和環(huán)境依賴(lài)。
main(主倉(cāng)庫(kù))
來(lái)源:
- 由Anaconda官方維護(hù)
內(nèi)容:
- 包含Anaconda官方認(rèn)證的、經(jīng)過(guò)嚴(yán)格測(cè)試的穩(wěn)定版本軟件包。
- 通常是較為成熟的軟件,更新頻率較低,但穩(wěn)定性高。
用途:
- 適合生產(chǎn)環(huán)境或需要穩(wěn)定版本的場(chǎng)景。
free(免費(fèi)倉(cāng)庫(kù))
來(lái)源:
- Anaconda 官方維護(hù),但已逐漸被棄用。
內(nèi)容:
- 早期Anaconda將部分包標(biāo)記為free(開(kāi)源免費(fèi))和non-free(商業(yè)許可)。
- 現(xiàn)在大多數(shù)包已遷移到 main 或 conda-forge,因此 free 倉(cāng)庫(kù)中的包較少。
注意:新版本Conda可能不再默認(rèn)使用free,建議優(yōu)先使用main或conda-forge。
conda-forge(社區(qū)倉(cāng)庫(kù))
來(lái)源:
- 由社區(qū)維護(hù)(非官方)。
內(nèi)容:
- 包含大量最新的開(kāi)源軟件包,更新頻繁,版本較新。
- 許多前沿工具(如機(jī)器學(xué)習(xí)庫(kù))會(huì)優(yōu)先發(fā)布到 conda-forge。
特點(diǎn):
- 包數(shù)量遠(yuǎn)超 main,但穩(wěn)定性可能略低(未經(jīng) Anaconda 官方全面測(cè)試)。
- 與 main 倉(cāng)庫(kù)可能存在依賴(lài)沖突,建議單獨(dú)使用或通過(guò)環(huán)境管理隔離。
用途:
- 適合開(kāi)發(fā)、測(cè)試或需要最新版本的場(chǎng)景。
其他常見(jiàn)庫(kù)
msys2:提供 Windows 系統(tǒng)的工具鏈(如 GCC、Git)。pytorch:PyTorch 官方維護(hù)的倉(cāng)庫(kù)。tensorflow:TensorFlow 官方倉(cāng)庫(kù)(Google 維護(hù))nvidia:NVIDIA GPU 相關(guān)工具(CUDA、cuDNN 等)fastai:Fast.ai 相關(guān)的深度學(xué)習(xí)工具bioconda:生物信息學(xué)領(lǐng)域的專(zhuān)用包。ioam:地理空間數(shù)據(jù)處理(如 geopandas 的早期版本)plotly:Plotly 交互式可視化工具。omnia:分子動(dòng)力學(xué)模擬工具(如 OpenMM)。r:R語(yǔ)言及其科學(xué)計(jì)算包。
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
django+celery+RabbitMQ自定義多個(gè)消息隊(duì)列的實(shí)現(xiàn)
本文主要介紹了django+celery+RabbitMQ自定義多個(gè)消息隊(duì)列的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-02-02
python opencv實(shí)現(xiàn)圖像配準(zhǔn)與比較
這篇文章主要為大家詳細(xì)介紹了python opencv實(shí)現(xiàn)圖像配準(zhǔn)與比較,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-02-02
Tortoise-orm信號(hào)實(shí)現(xiàn)及使用場(chǎng)景源碼詳解
這篇文章主要為大家介紹了Tortoise-orm信號(hào)實(shí)現(xiàn)及使用場(chǎng)景源碼詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03
Python實(shí)現(xiàn)8個(gè)概率分布公式的方法詳解
在本文中,我們將介紹一些常見(jiàn)的分布(均勻分布、高斯分布、對(duì)數(shù)正態(tài)分布等)并通過(guò)Python代碼進(jìn)行可視化以直觀地顯示它們,感興趣的可以學(xué)習(xí)一下2022-05-05
django-rest-framework解析請(qǐng)求參數(shù)過(guò)程詳解
這篇文章主要介紹了django-rest-framework解析請(qǐng)求參數(shù)過(guò)程詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-07-07
簡(jiǎn)單示例解析python爬蟲(chóng)IP的使用(小白篇)
這篇文章主要為大家通過(guò)簡(jiǎn)單示例解析python爬蟲(chóng)IP的使用介紹,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-06-06

