操作系统:Ubuntu 18.04
Python版本:3.6.2
1、安装基础开发库
apt-get install gcc
apt-get install openssl libssl-dev
2、安装数据库和开发库
apt-get install mysql-server libmysqld-dev
3、到官方网站下载python3.6.2源码包
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
4、解压、安装 步骤如下
tar -xvf Python-3.6.2.tgz
cd Python-3.6.2/
./configure --prefix=/opt/python3.6
make
make install
echo "export PATH=/opt/python3.6/bin:\$PATH" > /etc/profile.d/python.sh
echo $PATH
which python
mkdir ~/.python-eggs
chmod +w ~/.python-eggs
echo "export PATH=/opt/python3.6/bin:\$PATH" > /etc/profile.d/python.sh
export PATH=/opt/python3.6/bin:$PATH
5、验证是否安装完成
安装完成后可以通过执行python命令验证,如下:
# python3 -V
Python 3.6.2