本文转载自博客园ESHLkangi:https://www.cnblogs.com/ESHLkangi/p/8545979.html
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
新建个/usr/download 文件夹
mkdir /usr/download
在download文件夹下下载安装包(/usr/download )
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
解压文件
tar -xvf Python-3.6.4.tgz
创建安装文件的路径
mkdir /usr/local/python3
./configure --prefix=/usr/local/python3
make
make install
修改旧版本
mv /usr/bin/python /usr/bin/python_bak
创建新的软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python
检查python的版本
python -V
将/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
保存退出后,执行以下命令,让上一步修改成功
source ~/.bash_profile
完成!