Python?Anaconda以及Pip配置清華鏡像源代碼示例
前言
提示:
最近換了新電腦,在使用Anaconda安裝Python包時,系統(tǒng)會自動從默認源下載安裝包,但是由于網(wǎng)絡(luò)訪問限制或網(wǎng)絡(luò)連接速度較慢等原因,會導致安裝失敗或安裝速度較慢。
因此,為了提高安裝速度和穩(wěn)定性,一些用戶選擇使用國內(nèi)的鏡像源,如清華鏡像源。配置清華鏡像源可以讓用戶從國內(nèi)的服務(wù)器上下載Python包,這可以加快下載速度,并減少由于網(wǎng)絡(luò)訪問限制導致的下載失敗等問題。
一、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/
中國科學技術(shù)大學
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/
總結(jié)
到此這篇關(guān)于Python Anaconda以及Pip配置清華鏡像源的文章就介紹到這了,更多相關(guān)Anaconda及Pip配置清華鏡像源內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python實現(xiàn)截圖生成符合markdown的鏈接
之前是用的是typora來寫的文章,最近typora最近開始收費了,所以就不想用了,于是找到了一個替代品MarkText。本文將介紹如何通過Python實現(xiàn)截圖自動生成符合markdown的鏈接,感興趣的可以了解一下2022-01-01
Python數(shù)據(jù)類型--字典dictionary
這篇文章主要介紹了Python數(shù)據(jù)類型字典dictionary,字典是另一種可變?nèi)萜髂P?,且可存儲任意類型對象。下面詳細?nèi)容需要的小伙伴可以參考一下,希望對你有所幫助2022-02-02
Python使用Ollama實現(xiàn)私有大模型知識庫
這篇文章主要介紹了Python使用Ollama實現(xiàn)私有大模型知識庫,在不依賴LangChain、LlamaIndex等框架的前提下,盡量減少第三方庫的使用,僅通過Ollama和NumPy兩個外部庫來實現(xiàn)RAG,需要的朋友可以參考下2022-01-01
Python3多進程 multiprocessing 模塊實例詳解
這篇文章主要介紹了Python3多進程 multiprocessing 模塊,結(jié)合實例形式詳細分析了Python3多進程 multiprocessing 模塊的概念、原理、相關(guān)方法使用技巧與注意事項,需要的朋友可以參考下2018-06-06

