3dfx232 发表于 2018-12-11 20:40:45

让PIP源使用国内镜像,提升下载速度和安装成功率

本帖最后由 3dfx232 于 2018-12-13 17:31 编辑

一,更换系统源:
首先备份系统源
sudo cp /etc/apt/sources.list/etc/apt/sources.list.bak
将sources.list更换成下面的源
清华大学源:

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial universe
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates universe
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security universe
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security multiverse

更新下源
sudo apt-get update

二,更换pip源
在用户(/home/name/)目录下创建.pip文件夹,并创建pip.conf文件
Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)

内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

trusted-host=mirrors.aliyun.com

windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini。内容同上。

shaoheshaohe 发表于 2018-12-13 09:37:13

very useful
thanks

lsh 发表于 2019-2-8 13:48:36

much faster rate is achieved
after changing the source

very useful!

lsh 发表于 2019-2-8 13:50:07

I think,
more intelligent choice is required
to, at first, determine the address, e.g., domestic or international,
and then,
to, choose the proper pip/apt source

lsh 发表于 2019-2-8 13:50:37

anyway,

this is very useful and solves my big problem
页: [1]
查看完整版本: 让PIP源使用国内镜像,提升下载速度和安装成功率