Conda國內(nèi)鏡像源及配置過程
一、Conda國內(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/ # 中國科學(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/ # 北京外國語大學(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臨時使用鏡像源
指定單個源
- 直接使用鏡像站URL
conda install -c https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/ package_name
- 或者使用鏡像源的別名
conda install -c conda-forge package_name
臨時指定多個源
- Conda按優(yōu)先級從左到右依次搜索
-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)境時臨時指定源
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永久配置鏡像源
通過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
- 在用戶目錄下創(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 文件(簡單粗暴)
rm ~/.condarc
- 或者手動移除 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/
四、倉庫說明
main、free和conda-forge是不同的軟件包倉庫,它們提供不同類型的Python包和環(huán)境依賴。
main(主倉庫)
來源:
- 由Anaconda官方維護(hù)
內(nèi)容:
- 包含Anaconda官方認(rèn)證的、經(jīng)過嚴(yán)格測試的穩(wěn)定版本軟件包。
- 通常是較為成熟的軟件,更新頻率較低,但穩(wěn)定性高。
用途:
- 適合生產(chǎn)環(huán)境或需要穩(wěn)定版本的場景。
free(免費(fèi)倉庫)
來源:
- Anaconda 官方維護(hù),但已逐漸被棄用。
內(nèi)容:
- 早期Anaconda將部分包標(biāo)記為free(開源免費(fèi))和non-free(商業(yè)許可)。
- 現(xiàn)在大多數(shù)包已遷移到 main 或 conda-forge,因此 free 倉庫中的包較少。
注意:新版本Conda可能不再默認(rèn)使用free,建議優(yōu)先使用main或conda-forge。
conda-forge(社區(qū)倉庫)
來源:
- 由社區(qū)維護(hù)(非官方)。
內(nèi)容:
- 包含大量最新的開源軟件包,更新頻繁,版本較新。
- 許多前沿工具(如機(jī)器學(xué)習(xí)庫)會優(yōu)先發(fā)布到 conda-forge。
特點:
- 包數(shù)量遠(yuǎn)超 main,但穩(wěn)定性可能略低(未經(jīng) Anaconda 官方全面測試)。
- 與 main 倉庫可能存在依賴沖突,建議單獨使用或通過環(huán)境管理隔離。
用途:
- 適合開發(fā)、測試或需要最新版本的場景。
其他常見庫
msys2:提供 Windows 系統(tǒng)的工具鏈(如 GCC、Git)。pytorch:PyTorch 官方維護(hù)的倉庫。tensorflow:TensorFlow 官方倉庫(Google 維護(hù))nvidia:NVIDIA GPU 相關(guān)工具(CUDA、cuDNN 等)fastai:Fast.ai 相關(guān)的深度學(xué)習(xí)工具bioconda:生物信息學(xué)領(lǐng)域的專用包。ioam:地理空間數(shù)據(jù)處理(如 geopandas 的早期版本)plotly:Plotly 交互式可視化工具。omnia:分子動力學(xué)模擬工具(如 OpenMM)。r:R語言及其科學(xué)計算包。
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Django查詢數(shù)據(jù)庫的性能優(yōu)化示例代碼
這篇文章主要給大家介紹了關(guān)于Django查詢數(shù)據(jù)庫性能優(yōu)化的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2017-09-09
使用Python搭建輕量級靜態(tài)網(wǎng)頁服務(wù)器的示例詳解
這篇文章主要為大家詳細(xì)介紹了如何使用Python搭建一個輕量級靜態(tài)網(wǎng)頁服務(wù)器,零基礎(chǔ)也能實現(xiàn)的Web開發(fā)初體驗,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2025-07-07
Python?pandas修剪函數(shù)clip使用實例探究
在數(shù)據(jù)處理和分析中,經(jīng)常面臨著需要限制數(shù)據(jù)范圍的情況,而pandas庫提供的clip函數(shù)就是一個強(qiáng)大的工具,可以方便地對數(shù)據(jù)進(jìn)行修剪,本文將深入介紹clip函數(shù)的基本用法、常見參數(shù)以及實際場景中的應(yīng)用,以幫助大家充分理解并靈活運(yùn)用這一功能2024-01-01
Python 二進(jìn)制字節(jié)流數(shù)據(jù)的讀取操作(bytes與bitstring)
本文主要介紹了Python 二進(jìn)制字節(jié)流數(shù)據(jù)的讀取操作(bytes與bitstring),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-03-03
python已協(xié)程方式處理任務(wù)實現(xiàn)過程
這篇文章主要介紹了python已協(xié)程方式處理任務(wù)實現(xiàn)過程,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2019-12-12
簡單了解python gevent 協(xié)程使用及作用
這篇文章主要介紹了簡單了解python gevent 協(xié)程,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2019-07-07
如何將PySpark導(dǎo)入Python的放實現(xiàn)(2種)
這篇文章主要介紹了如何將PySpark導(dǎo)入Python的放實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-04-04

