2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > ubuntu18安装python3.6.8_ubuntu 18.04 + Python 3.6.8 更换软件安装源

ubuntu18安装python3.6.8_ubuntu 18.04 + Python 3.6.8 更换软件安装源

时间:2018-12-15 04:28:33

相关推荐

ubuntu18安装python3.6.8_ubuntu 18.04 + Python 3.6.8 更换软件安装源

国外的开源项目开展的是如火如荼,我们国内的当然也不甘落后。为了更好的玩转 Python,我使用了 ubuntu Linux 来作为开发环境。但是由于国内网络的限制,访问国外的一些软件源的时候,速度比较慢,这时我们需要更换成国内的软件源。

1、更换 ubuntu 18.04 的软件安装源

查看Ubuntu18版本和codename(一定要注意codename对应)

$ lsb_release -a

No LSB modules are available.

Distributor ID: Ubuntu

Description: Ubuntu 18.10

Release: 18.10

Codename: cosmic

备份系统默认的软件源

cp

/etc/apt/sources.list /etc/apt/sources.list.bak

创建新的

sources.list

文件

vim /etc/apt/sources.list

将以下内如写入到文件中并保存。

deb https://mirrors./ubuntu/ cosmic main restricted universe multiverse

deb-src https://mirrors./ubuntu/ cosmic main restricted universe multiverse

deb https://mirrors./ubuntu/ cosmic-updates main restricted universe multiverse

deb-src https://mirrors./ubuntu/ cosmic-updates main restricted universe multiverse

deb https://mirrors./ubuntu/ cosmic-backports main restricted universe multiverse

deb-src https://mirrors./ubuntu/ cosmic-backports main restricted universe multiverse

deb https://mirrors./ubuntu/ cosmic-security main restricted universe multiverse

deb-src https://mirrors./ubuntu/ cosmic-security main restricted universe multiverse

deb https://mirrors./ubuntu/ cosmic-proposed main restricted universe multiverse

deb-src https://mirrors./ubuntu/ cosmic-proposed main restricted universe multiverse

更新软件源

sudo

apt update

&

apt upgrade

2、更换 pip 的软件源

方案一:临时给pip 或 pip3换源

命令格式:sudo pip3

install

包名 -i 镜像源url

比如我在用pip3安装Python模块matplotlib的时候,下载速度只有是几k,换成如下方式之后下载速度提到了1-2MB/s左右

sudo

pip3

install

matplotlib -i /simple/

sudo

pip3

install

matplotlib -i /simple/

搞定之后速度快到起飞。

方案二:永久给pip 或 pip3换源

1) 回到当前用户主目录

$

cd

~

2) 创建文件夹

mkdir

~/.pip

cd

~/.pip/

3) 修改配置文件

vim pip.conf

添加如下内容:

[

global

]

index-url

=

/simple

[

install

]

trusted-host

=

国内其他pip源

清华:https://pypi.tuna./simple

中国科技大学 https://pypi.mirrors./simple/

华中理工大学:/

山东理工大学:/

豆瓣:/simple/

注意:不管你用的是pip3还是pip,方法都是一样的,都是创建pip文件夹。

完成这些之后,你可以在 linux 系统上自由的飞翔啦。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。