本文转载自博客园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
完成!
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有