1、安装依赖环境
# 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
2、下载Python3(https://www.python.org/downloads/)
# wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
3、安装python3
1)、创建目录:/usr/local/python3(具体安装位置看个人喜好)
# mkdir -p /usr/local/python3
2)、解压下载好的Python-3.x.x.tgz包(具体包名因你下载的Python具体版本不不同⽽而不不同
# tar -zxvf Python-3.6.1.tgz
3)、进入解压后的目录,编译安装。
# cd Python-3.6.1
# ./configure --prefix=/usr/local/python3
4)、进行make
# make
5)、进行make install
#make install
4、建立python3的软链
# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
5、将/usr/local/python3/bin加入PATH
# vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
export PATH
按ESC,输入:wq回车退出。
让上一步的修改生效:
# source ~/.bash_profile
6、检查Python3是否正常可用:
# python3 -V
Python 3.7.3