Centos7升级Python2到Python3

Posted wx580ec8c84ec69

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7升级Python2到Python3相关的知识,希望对你有一定的参考价值。

安装依赖包

> yum install -y libffi-devel

安装python 3.7.3

# 下载
> wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
# 解压
> tar -zxf Python-3.7.3.tgz
# 安装依赖包
> yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc  libffi-devel
# 进入python目录
> cd Python-3.7.3
# 编译
> ./configure --prefix=/usr/local/python3.7
#安装
> make && make install

备份Python2版本

>mv /usr/bin/python /usr/bin/python.bak
> ln -s /usr/local/python/bin/python3.7 /usr/bin/python

查看Python版本

> python -V

更改yum配置

  • 编辑这两个文件,将文件头的#!/usr/bin/python改为#!/usr/bin/python2
> vim /usr/bin/yum
> vim /usr/libexec/urlgrabber-ext-down

原文链接:https://rumenz.com/rumenbiji/centos7-python2-to-python3.html
微信公众号:入门小站

以上是关于Centos7升级Python2到Python3的主要内容,如果未能解决你的问题,请参考以下文章

Centos7升级Python2到Python3

Centos7升级Python2到Python3

Centos7.4系统Python2.7升级Python3.6(编译安装)

centos7 python2升级python3

Linux笔记-Centos7将python2升级为python3(及修改yum配置防报错)

centos7 一键升级python3