python安装第三方库--换镜像源

python安装第三方库的tips:

用conda安装:conda install xxx or conda install xxx.txt

用pip安装:pip install xxx or pip install -r xxx.txt

用其他源安装第三方库:conda/pip install xxx -i https://pypi.mirrors.ustc.edu.cn/simple/

阿里源:https://mirrors.aliyun.com/pypi/simple

中科大源:https://pypi.mirrors.ustc.edu.cn/simple/

python工具包网址:工具包地址,用该命令安装下载好的工具包

python安装第三方库--换镜像源

1. 更换anaconda源

清华大学镜像:清华大学镜像

anaconda下载地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

更换仓库镜像源命令:

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 --set show_channel_urls yes

2. 更换pip源

在python安装目录的bin目录下运行命令:

cd ~/.pip

如果不存在该文件夹则:

mkdir ~/.pip
cd ~/.pip
touch pip.conf
vim pip.conf

在pip.conf中添加如下内容:

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

保存即配置好了pip镜像源。

3. 以下载pytorch0.4.0为例

sudo pip install torch==0.4.0 -f https://download.pytorch.org/whl/cu90/stable

运行上述命令即可快速下载pytorch0.4.0

参考博客:

安装Pytorch0.4.0需要填的坑

原文地址:https://www.cnblogs.com/shyern/p/11284652.html