完美原创:centos7.1 从源码升级安装Python3.5.2

时间:2021-02-02 03:06:08

(原创)完美原创:centos7.1 从源码升级安装Python3.5.2





下载Python3.5.2源码:https://www.python.org/downloads/release/python-352/





解压到 /opt目录下

tar zxvf Python-3.5.2.tgz -C /opt/





改名为python352:

cd /opt

mv Python-3.5.2 python352





创建安装目录:mkdir /usr/local/python3.5.2

查看是否安装 rpm -qa | grep openssl-devel

没有就安装

yum install openssl-devel

检查编译环境:./configure --prefix=/usr/local/python3.5.2





编译:make





生成安装包:make install





配置环境:

a.先修改老的连接,执行:mv /usr/bin/python /usr/bin/python_bak

b.建立python新连接: ln -s /usr/local/python3.5.2/bin/python3.5 /usr/bin/python

b.建立pip新连接: ln -s /usr/local/python3.5.2/bin/pip3.5 /usr/bin/pip





大功告成

查询python版本,执行:python





显示:

Python 3.5.2 (default, Dec  9 2016, 09:15:55) 

[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux

Type "help", "copyright", "credits" or "license" for more information.





修改 yum程序保证其可用

vi /usr/bin/yum 

将: 将首行#!/usr/bin/python改成#!/usr/bin/python2.7 或修改成/usr/bin/python_bak 即可





重启后检验一下:reboot

一切完美!收工!任何疑问请联系我本人 QQ:99923309