CentOS 6编译安装python 3.6.1

前端之家收集整理的这篇文章主要介绍了CentOS 6编译安装python 3.6.1前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

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

# cat /etc/redhat-release

# python -V

wKiom1jjRYCzaxPHAABQLfg6wdA818.jpg

二、编译安装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

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

# date 040413022017.30

# date

3、编译安装Python-3.6.1

#wgethttps://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz

# 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 //此步骤过程中需要执行测试,用时较长

wKioL1jjRZvwAgwEAABvO_NBwYA501.jpg

4、更改CentOS6默认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

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

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版本:

# python3 -V

wKiom1jjRa-Q_rdMAAA85B-C9X4301.jpg

三、将yum中的版本修改为系统原来的2.6.6升级Python后会导致yum无法使用:

wKioL1jjRdyzSQlYAABfo5KtF0U586.jpg

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

wKiom1jjRezxJb21AAH5oSAd23o555.jpg


添加:安装pip方法

首先安装epel扩展源:

#yum -y install epel-release

然后再安装pip

#yum -y install python-pip


centos查找命令

find/-name"pip*"

1、安装python3.6.1

2、安装setuptools35.0.2

3、安装pip

#easy_install pip

本文出自 “天道酬勤博客,请务必保留此出处http://qiuyue.blog.51cto.com/1246073/1912806

猜你在找的CentOS相关文章