Python3.7 源码下载:
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
解压源码:
tar -zxvf Python-3.7.1.tgz -C /opt
安装源码编译所需的各种依赖库:(Ubuntu16.04环境下)
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
配置安装位置 配置优化:
首先要进入到刚才解压的目录下,即为/opt/python3.7.1,再执行如下命令
./configure --prefix=/opt/python3.7.1 --enable-optimizations
编译:
make -j 4
安装:
sudo make install
也或者编译、安装一起:
sudo make && sudo make install
设置python3.7.1版本为默认python
sudo rm /usr/bin/python
sudo ln -s /opt/python3.7/bin/python3.7 /usr/bin/python