CentOS 6编译安装python 3.6.1

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

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

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

# cat /etc/redhat-release@H_301_3@

# python -V@H_301_3@

wKiom1jjRYCzaxPHAABQLfg6wdA818.jpg

@H_301_3@

二、编译安装@H_301_3@Python-3.6.1@H_301_3@:@H_301_3@

1、@H_301_3@安装依赖软件包:@H_301_3@

# yum -y groupinstall "Development tools"@H_301_3@

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

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

# date 040413022017.30@H_301_3@

# date@H_301_3@

3、@H_301_3@编译安装@H_301_3@Python-3.6.1@H_301_3@:@H_301_3@

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

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

# cd /usr/src/Python-3.6.1@H_301_3@

# ./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@H_301_3@

# make && make install //@H_301_3@此步骤过程中需要执行测试,用时较长@H_301_3@

wKioL1jjRZvwAgwEAABvO_NBwYA501.jpg

4、@H_301_3@更改@H_301_3@CentOS6@H_301_3@默认@H_301_3@Python@H_301_3@版本为@H_301_3@3.6.1@H_301_3@:@H_301_3@

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

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

5、@H_301_3@添加至@H_301_3@PATH@H_301_3@环境变量:@H_301_3@

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

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

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

# echo $PATH@H_301_3@

6、@H_301_3@配置头文件:@H_301_3@

# ln -sv /usr/local/python3.6.1/include /usr/include/python3.6@H_301_3@

7、@H_301_3@配置库文件:@H_301_3@

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

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

# ldconfig@H_301_3@

8、@H_301_3@配置@H_301_3@man@H_301_3@帮助文档:@H_301_3@

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

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

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

# python3 -V@H_301_3@

wKiom1jjRa-Q_rdMAAA85B-C9X4301.jpg

@H_301_3@

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

wKioL1jjRdyzSQlYAABfo5KtF0U586.jpg

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

wKiom1jjRezxJb21AAH5oSAd23o555.jpg


添加:安装pip方法@H_301_3@

首先安装epel扩展源:@H_301_3@

#yum -y install epel-release

@H_301_3@
然后再安装pip
@H_301_3@

#yum -y install python-pip@H_301_3@


@H_301_3@

centos查找命令@H_301_3@

@H_301_3@

find/-name"pip*"

@H_301_3@1、安装python3.6.1

2、安装setuptools35.0.2

3、安装pip

#easy_install pip@H_301_3@

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

猜你在找的CentOS相关文章