centos7编译安装Python3.6(与2.7并存)

原文是:https://www.cnblogs.com/Sargreis/p/6921379.html

首先去官网下载python3.6

https://www.python.org/

环境准备:yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

mkdir /usr/local/python3

准备安装python

./configure --prefix=/usr/local/python3 --enable-optimizations

make

makeinstall

ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3

ln -s /usr/local/python3/bin/pip /usr/bin/pip3

cd /usr/bin

mv python python.bak

mv python3 python

在etc/profile最后一行中加入变量

export PATH="$PATH:/usr/local/python3/bin"

输入python -V 可以看到版本号

输入pip -V 可以看到新的位置


如果yum 安装报错 File "/usr/bin/yum", line 30 except KeyboardInterrupt, e:

因为yum包使用python2*等开发,修该为环境修改python3之后有问题,

解决:

修改文件/usr/bin/yum、/usr/libexec/urlgrabber-ext-down头中相应python为#!/usr/bin/python2.7

你可能感兴趣的:(centos7编译安装Python3.6(与2.7并存))