簡述:
使用Anaconda在安裝程序時,由於源在國外的原因,下載速度慢,時常出現read time out。看了許多的博客,瞭解到通過換源的方法,將國外源換成國內源,能夠使下載速度飛昇。
本文介紹了windows與Ubuntu上換源的方法,最後介紹了一個真實有效的快速下載方法。
國內安裝源主要有:阿里、清華、中科大、豆瓣等。
Windows換源(以清華源爲例)
方法一:
打開cmd;
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
# 設置搜索時顯示通道地址
conda config --set show_channel_urls yes
方法二:
打開C盤中的用戶文件夾中的用戶文件,例如C:\Users\QIAN;
找到最後的.condarc文件,使用記事本打開,把上述代碼複製到.condarc中保存,如下圖:
可能出現的問題:
即使按照方法一、方法二操作了,依舊沒有效果。
解決辦法:
打開.condarc,將 - defaults行刪除,保存。
Ubuntu 換源(以清華源爲例)
使用gedit或者vim打開.condarc文件,修改保存即可。例如使用gedit:
gedit ~/.condarc
channels:
- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
- https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
show_channel_urls: true
真實有效的方法:
個人換源後,有時在環境裏使用pip安裝模塊的時候,下載速度並不是很快,通過閱讀《pip 更換國內安裝源 阿里源 清華源 豆瓣源等等》一文,發現文中介紹的方法在應用中,下載是的確快,很實用。國內pip下載源如下:
清華:https://pypi.tuna.tsinghua.edu.cn/simple
阿里雲:http://mirrors.aliyun.com/pypi/simple/
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
華中理工大學:http://pypi.hustunique.com/
山東理工大學:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
在使用pip 安裝時,使用 -i 參數,將源導入即可。例如使用清華源安裝numpy:
pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple