Ubantu更換pip與conda下載源

conda換清華源

打開終端輸入以下命令:

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/main/
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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes 

輸入以下命令查看是否換源成功:

conda config --show channels

pip換清華源、豆瓣源

打開終端輸入以下命令:

如果不存在隱藏的pip文件夾,則創建它:

mkdir ~/.pip

進入該文件內:

cd ~/.pip

創建pip.conf文件:

touch pip.conf

編輯pip.conf文件:

sudo gedit ~/.pip/pip.conf

在pip.conf文件中寫入如下內容,換爲豆瓣源(強烈推薦),然後保存並退出文件:

[global]
index-url = http://pypi.douban.com/simple/
[install]
trusted-host = pypi.douban.com

或者換爲清華源

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/ 
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn

輸入以下命令查看是否換源成功:

pip config list

參考文章:https://blog.csdn.net/moshiyaofei/article/details/86529216

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章