查看: 1819|回复: 4

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

[复制链接]

81

主题

162

帖子

493

积分

推广大使

积分
493
发表于 2018-12-11 20:40:45 | 显示全部楼层 |阅读模式
本帖最后由 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
[install]
trusted-host=mirrors.aliyun.com

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

回复

使用道具 举报

665

主题

1234

帖子

6576

积分

xdtech

Rank: 5Rank: 5

积分
6576
发表于 2018-12-13 09:37:13 | 显示全部楼层
very useful
thanks
回复

使用道具 举报

38

主题

84

帖子

243

积分

中级会员

Rank: 3Rank: 3

积分
243
发表于 2019-2-8 13:48:36 | 显示全部楼层
much faster rate is achieved
after changing the source

very useful!
回复

使用道具 举报

38

主题

84

帖子

243

积分

中级会员

Rank: 3Rank: 3

积分
243
发表于 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
回复

使用道具 举报

38

主题

84

帖子

243

积分

中级会员

Rank: 3Rank: 3

积分
243
发表于 2019-2-8 13:50:37 | 显示全部楼层
anyway,

this is very useful and solves my big problem
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表