使用国内的数据源,是为了提高安装包的下载速度。
更换apt-get数据源:
vim /etc/apt/sources.list
例如,更换为交通大学数据源:
# deb cdrom:[Ubuntu 16.04.4 LTS _Xenial Xerus_ - Release amd64 (20180228)]/ xenial main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://ftp.sjtu.edu.cn/ubuntu/ xenial main restricted
deb-src http://ftp.sjtu.edu.cn/ubuntu/ xenial main restricted universe multiverse #Added by software-properties
## Major bug fix updates produced after the final release of the
## distribution.
deb http://ftp.sjtu.edu.cn/ubuntu/ xenial-updates main restricted
deb-src http://ftp.sjtu.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse #Added by software-properties
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://ftp.sjtu.edu.cn/ubuntu/ xenial universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial universe
deb http://ftp.sjtu.edu.cn/ubuntu/ xenial-updates universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://ftp.sjtu.edu.cn/ubuntu/ xenial multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://ftp.sjtu.edu.cn/ubuntu/ xenial-updates multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://ftp.sjtu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://ftp.sjtu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://ftp.sjtu.edu.cn/ubuntu/ xenial-security main restricted
deb-src http://ftp.sjtu.edu.cn/ubuntu/ xenial-security main restricted universe multiverse #Added by software-properties
deb http://ftp.sjtu.edu.cn/ubuntu/ xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb http://ftp.sjtu.edu.cn/ubuntu/ xenial-security multiverse
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse
刷新:
sudo apt-get update
sudo apt-get upgrade
pip3的安装与升级:
sudo apt-get install python3-pip
sudo pip3 install --upgrade pip
查看pip版本:
pip -V
pip源更换:
在当前用户的主目录下创建 .pip 文件夹:
mkdir ~/.pip
在.pip文件夹下新建文件pip.conf:
vim .pip/pip.conf
编辑内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
这个更换的是清华的源,清华的源5分钟同步官网一次,建议使用。
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
修改默认python版本
我们也可以把Ubuntu的默认python版本号进行修改,步骤如下:
删除原有Python连接文件
sudo rm /usr/bin/python
建立指向Python3的连接:
ln -s /usr/bin/python3.6 /usr/bin/python
以上操作就是完成默认Python版本设置,
查看默认版本号:
python -V