Python?Anaconda以及Pip配置清華鏡像源代碼示例
前言
提示:
最近換了新電腦,在使用Anaconda安裝Python包時,系統(tǒng)會自動從默認(rèn)源下載安裝包,但是由于網(wǎng)絡(luò)訪問限制或網(wǎng)絡(luò)連接速度較慢等原因,會導(dǎo)致安裝失敗或安裝速度較慢。
因此,為了提高安裝速度和穩(wěn)定性,一些用戶選擇使用國內(nèi)的鏡像源,如清華鏡像源。配置清華鏡像源可以讓用戶從國內(nèi)的服務(wù)器上下載Python包,這可以加快下載速度,并減少由于網(wǎng)絡(luò)訪問限制導(dǎo)致的下載失敗等問題。
一、Conda配置清華鏡像源
1. 查看鏡像源
conda config --show channels
2. 刪除添加源,恢復(fù)默認(rèn)源
conda config --remove-key channels
3. 添加清華鏡像源
#添加鏡像源 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main 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/r conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 #終端顯示包從哪個channel下載,以及下載地址是什么 conda config --set show_channel_urls yes
二、Pip配置清華鏡像源
1. 臨時使用清華鏡像源
代碼如下(示例):
# some-package代表你需要安裝的包 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
下面這種方式也是一樣的
pip install some-package -i https://pypi.tuna.tsinghua.edu.cn/simple
2.永久配置
代碼如下(示例):
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
三、國內(nèi)常用的鏡像源
pip install -i https://mirrors.aliyun.com/pypi/simple/ some-package 清華大學(xué)開源軟件鏡像站:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云開源鏡像站:https://mirrors.aliyun.com/pypi/simple/ 豆瓣:https://pypi.douban.com/simple/ 中國科技大學(xué) https://pypi.mirrors.ustc.edu.cn/simple/
上海交通大學(xué)開源鏡像站
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
中國科學(xué)技術(shù)大學(xué)
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
華中理工大學(xué):
conda config --add channels http://pypi.hustunique.com/
山東理工大學(xué):
conda config --add channels http://pypi.sdutlinux.org/
總結(jié)
到此這篇關(guān)于Python Anaconda以及Pip配置清華鏡像源的文章就介紹到這了,更多相關(guān)Anaconda及Pip配置清華鏡像源內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
一文詳解Python中的日期計(jì)算和自動化運(yùn)行腳本
詳解Python的整數(shù)是如何實(shí)現(xiàn)的
keras訓(xùn)練曲線,混淆矩陣,CNN層輸出可視化實(shí)例
一篇文章告訴你如何用Python控制Excel實(shí)現(xiàn)自動化辦公
Python實(shí)現(xiàn)刪除Android工程中的冗余字符串

