centos中python2.7升级3.7
wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
tar xf Python-3.7.2.tgz
cd Python-3.7.2.tgz
安装依赖包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 gcc gcc-lib gcc-c++ zlib libffi-devel
./configure --prefix=/usr/local/python3
make && make install
备份原有的python以便后期恢复
mv /usr/bin/python mv/usr/bin/python2.7.5
接下来需要修改yum配置文件,否则yum将无法使用
vi /usr/bin/yum
把配置文件头#!/usr/bin/python 改成#!/usr/bin/python2.7.5
之后建立新的链接 ln -s /usr/local/python3/bin/python3.7 /usr/bin/python
上面建立软连接不行则:ln -snf /usr/local/python3/bin/python3.7 /usr/bin/python3
最后检查python指向是否成功
python -V
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 晚风如诉!
评论