繼上一篇《在WSL上搭載python編程環境》以後,下載軟件和建立新環境的過程很是艱辛,下載太慢,以致於經常中斷。html
不論用conda安裝一些python的包,仍是創新獨立的編程環境時,出現如下報錯:python
在anaconda安裝完畢以後,一般要作的就是配置更新,這一步主要將conda下載源從國外的網站轉移到國內網站,這樣就能夠大大縮減下載時間,防止出現以上網絡問題。該問題的解決方法只有一種,那就是更換conda下載源。下載源一般位於~/.condarc文件中,或者/home/用戶名/.condarc文件中。編程
查看源的方式:vim
方法1:除了vim,也可用cat/more/less顯示網絡
1 vi ~/.condarc #對於root用戶 2 vi /home/xuran/.condarc #對於普通用戶
方法2:用conda show命令less
>> conda config --show #所有顯示網站
>> conda config --show channels #只顯示channels部分url
1 conda config --show #所有顯示 2 conda config --show channels #只顯示channels部分
更換源的方式:spa
方法1:直接使用清華源的.condarc文件,並放在相應的目錄下。code
下載地址https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
方法2:在(base)中輸入命令,添加源,並移除默認選項(default)
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --remove channels defaults conda config --set show_channel_urls yes
方法3:先用vim打開./condarc文件,而後手動添加源
#open .condarc file vi /home/xuran/.condarc #add the following code ssl_verify: true channels: - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
show_channel_urls: true
注意,channels不須要太多,前兩個就夠用。
有人反應用「https」會報錯,用「http」更穩定。
對於地震學經常使用的obspy包,前兩個沒有,用第三個channels下載更快一些。
分析了半天,發現緣由時個人源少打了一個字母,難怪下載不出來。
終於成功了