ubuntu 18 python3.6更换国内源和pip3源

1.更换国内源

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

1 lsb_release -a
1 No LSB modules are available.
2 Distributor ID:    Ubuntu
3 Description:    Ubuntu 18.10
4 Release:    18.10
5 Codename:    cosmic

先备份

cp /etc/apt/sources.list /etc/apt/sources.list.bak
 1 vim /etc/apt/sources.list
 2 
 5 deb https://mirrors.ustc.edu.cn/ubuntu/ cosmic main restricted universe multiverse
 6 deb-src https://mirrors.ustc.edu.cn/ubuntu/ cosmic main restricted universe multiverse
 7 deb https://mirrors.ustc.edu.cn/ubuntu/ cosmic-updates main restricted universe multiverse
 8 deb-src https://mirrors.ustc.edu.cn/ubuntu/ cosmic-updates main restricted universe multiverse
 9 deb https://mirrors.ustc.edu.cn/ubuntu/ cosmic-backports main restricted universe multiverse
10 deb-src https://mirrors.ustc.edu.cn/ubuntu/ cosmic-backports main restricted universe multiverse
11 deb https://mirrors.ustc.edu.cn/ubuntu/ cosmic-security main restricted universe multiverse
12 deb-src https://mirrors.ustc.edu.cn/ubuntu/ cosmic-security main restricted universe multiverse
13 deb https://mirrors.ustc.edu.cn/ubuntu/ cosmic-proposed main restricted universe multiverse
14 deb-src https://mirrors.ustc.edu.cn/ubuntu/ cosmic-proposed main restricted universe multiverse

更新

1 apt update
2 apt upgrade

结果显示很快的

2.更换豆瓣pip

创建文件夹

mkdir ~/.pip
cd ~/.pip/

编辑配置文件

1 vim pip.conf
2 [global] 
3 index-url = http://pypi.douban.com/simple 
4 [install] 
5 trusted-host=pypi.douban.com

安装pip3

1 pip install python3-pip

安装django速度25MB/s

pip3 install django

也可以每次使用单独的pip源

1 pip install pygame -i http://pypi.douban.com/simple
2 pip install pygame -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

 

转载于:https://www.cnblogs.com/Rightsec/p/11006081.html

你可能感兴趣的:(ubuntu 18 python3.6更换国内源和pip3源)