Python?Anaconda以及Pip配置清華鏡像源代碼示例
前言
提示:
最近換了新電腦,在使用Anaconda安裝Python包時,系統(tǒng)會自動從默認源下載安裝包,但是由于網(wǎng)絡訪問限制或網(wǎng)絡連接速度較慢等原因,會導致安裝失敗或安裝速度較慢。
因此,為了提高安裝速度和穩(wěn)定性,一些用戶選擇使用國內(nèi)的鏡像源,如清華鏡像源。配置清華鏡像源可以讓用戶從國內(nèi)的服務器上下載Python包,這可以加快下載速度,并減少由于網(wǎng)絡訪問限制導致的下載失敗等問題。
一、Conda配置清華鏡像源
1. 查看鏡像源
conda config --show channels
2. 刪除添加源,恢復默認源
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 清華大學開源軟件鏡像站:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云開源鏡像站:https://mirrors.aliyun.com/pypi/simple/ 豆瓣:https://pypi.douban.com/simple/ 中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
上海交通大學開源鏡像站
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/
中國科學技術大學
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/
華中理工大學:
conda config --add channels http://pypi.hustunique.com/
山東理工大學:
conda config --add channels http://pypi.sdutlinux.org/
總結
到此這篇關于Python Anaconda以及Pip配置清華鏡像源的文章就介紹到這了,更多相關Anaconda及Pip配置清華鏡像源內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
一篇文章告訴你如何用Python控制Excel實現(xiàn)自動化辦公
Python實現(xiàn)刪除Android工程中的冗余字符串

