CentOS 6.9编译安装python 3.6.1

Python官网:https://www.python.org/

一、查看CentOS版本和系统默认Python版本:

# cat /etc/redhat-release

# python -V

CentOS 6.9编译安装python 3.6.1

 

二、编译安装Python-3.6.1

1、安装依赖软件包:

# yum -y groupinstall "Development tools"

# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-develreadline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel man

2、设置CentOS6当前系统时间:

# date 040413022017.30

# date

3、配置主机名解析:# vim /etc/hosts  -->  127.0.0.1 localhost

4、编译安装Python-3.6.1

# tar xf Python-3.6.1.tar.xz -C /usr/src

# cd /usr/src/Python-3.6.1

# ./configure --prefix=/usr/local/python3.6.1 --enable-shared --enable-profiling--enable-optimizations --disable-ipv6 --with-threads --with-pymalloc --with-fpectl--enable-loadable-sqlite-extensions

# make && make install         //此步骤需要执行测试,用时较长

4、更改CentOS 6.9默认Python版本为3.6.1

# mv /usr/bin/python /usr/bin/python2.6.6-old

# ln -s /usr/local/python3.6.1/bin/python3 /usr/bin/python

# ln -s /usr/local/python3.6.1/bin/pip3 /usr/bin/pip

5、添加至PATH环境变量:

# vim /etc/profile.d/python3.6.1.sh

exportPATH=/usr/local/python3.6.1/bin:$PATH

# . /etc/profile.d/python3.6.1.sh

# echo $PATH

6、配置头文件:

# ln -sv /usr/local/python3.6.1/include /usr/include/python3.6.1

7、配置库文件:

# echo "/usr/local/python3.6.1/lib" >/etc/ld.so.conf.d/python3.6.1.conf

# cat /etc/ld.so.conf.d/python3.6.1.conf

# ldconfig

8、配置man帮助文档:

# vim /etc/man.config,新增如下代码:

MANPATH /usr/local/python3.6.1/share/man

9、查看配置后的Python版本:

# python -V

# python3 -V

CentOS 6.9编译安装python 3.6.1

 

三、将yum中的Python版本修改为系统原来的2.6.6版本:

升级Python后会导致yum无法使用:

CentOS 6.9编译安装python 3.6.1

# vim /usr/bin/yum,将第一行的“#!/usr/bin/python”修改为“#!/usr/bin/python2.6.6-old

CentOS 6.9编译安装python 3.6.1





      本文转自Marion0728  51CTO博客,原文链接:http://blog.51cto.com/qiuyue/1912806,如需转载请自行联系原作者




上一篇:“趋同”的云服务赛道,百度智能云将以“云+AI”全速发力


下一篇:centos6.5安装python3.5 和 ipython