1. 下载安装包
wget https://mirrors.huaweicloud.com/python/3.7.3/Python3.7.3.tgz
不设置代理的话官网下载速度相当慢,在这里通过华为的开源镜像站下载
2. 解压缩到指定文件夹
tar zxvf ./Python-3.7.3.tgz -C [指定解压缩的文件路径]
3.安装相关依赖
1. sudo apt-get update
2. sudo apt-get upgrade
3. sudo apt install make build-essential libssl-dev zlib1g-dev
4. sudo apt install libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm
5. sudo apt install libncurses5-dev libncursesw5-dev xz-utils tk-dev
4.编译安装
切换到解压之后的Python文件夹,执行下面的三行命令,即可完成编译安装。注意prefix之后是具体的安装路径,根据自己的需要可以修改.
./configure --with-ssl --prefix=/opt/python3.7
sudo make
sudo make install
5.建立软链接
因为Deepin自带了Python3.5,为了与Python3.5区分,在这里将软链接名字设置为python3.7和pip3.7.
ln -s /opt/python3.7/bin/python3.7 /usr/bin/python3.7
ln -s /opt/python3.7/bin/pip3.7 /usr/bin/pip3.7
一切顺利的话,在终端中输入python3.7即可进入Python解释器