在python2基础上同时安装python3安装,源码安装

当前机器版本

# python -V
Python 2.7.5

python2安装位置

# whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /usr/share/man/man1/python.1.gz

下载python3源码

# wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz

解压

# tar zxvf Python-3.8.0.tgz

安装编译过程中需要的依赖包

yum install gcc zlib zlib-devel openssl-devel readline readline-devel -y

进入解压目录

cd Python-3.8.0/

配置安装路径,支持ssl,编译安装

./configure --prefix=/usr/local/python3.8 --with-ssl
make && make install

配置环境变量

ln -s /usr/local/python3.8/bin/python3.8 /usr/bin/python3

测试

# python3 -V
Python 3.8.0

# python -V
Python 2.7.5

完成

你可能感兴趣的:(在python2基础上同时安装python3安装,源码安装)