本文转载自博客园ESHLkangi:https://www.cnblogs.com/ESHLkangi/p/8545979.html
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.6
新建个/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
3、安装Python3
创建安装文件的路径
mkdir /usr/local/python3
4、编译(在解压的文件夹下 /usr/download/python3.6.4)
./configure --prefix=/usr/local/python3
5、安装(在解压的文件夹下 /usr/download/python3.6.4)
make
make install
6、创建新版本的软链接
修改旧版本
mv /usr/bin/python /usr/bin/python_bak
创建新的软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python
检查python的版本
python -V
7、配置成功后,pip3用不了,需要进一步配置
将/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
完成!
网友评论