Ubuntu16.04安装Python3.7并设置为默认版本

1. 安装编译环境

sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev

2. 下载Python-3.7.1

wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1rc2.tgz

3. 解压文件

tar zxvf Python-3.7.1rc2.tgz

4. 编译安装

cd Python-3.7.1rc2
./configure --prefix=/usr/bin/python3.7
sudo make && sudo make install

该过程中可能出现的Error及解决方法:
zipimport.ZipImportError: can’t decompress data; zlib not available

ModuleNotFoundError: No module named ‘_ctypes’

5. 设置python3.7.1版本为默认python

sudo rm /usr/bin/python
sudo ln -s /usr/bin/python3.7/bin/python3.7 /usr/bin/python

你可能感兴趣的:(Ubuntu,Python)