安装依赖
Ubuntu/Debian下需安装的依赖:
sudo apt-get install -y gcc make cmake build-essential libssl-dev zlib1g-dev
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
Fedora/CentOS/RHEL(aws ec2)下需安装的依赖:
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
下载安装包
https://www.python.org/ftp/python/
cd /usr/local/
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
解压、编译、安装
解压
tar -zxvf Python-3.7.0.tgz
建立一个空文件夹,用于存放python3程序
mkdir /usr/local/python3
执行配置文件,编译,编译安装
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make && make install
创建软连接
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3