CentOS 6.9编译安装python
Python官网:https://www.python.org/
一、查看CentOS版本和系统默认Python版本:
# cat /etc/redhat-release
# python -V
二、编译安装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/class="lazy" data-src
# cd /usr/class="lazy" data-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
三、将yum中的Python版本修改为系统原来的2.6.6版本:
升级Python后会导致yum无法使用:
# vim /usr/bin/yum,将第一行的“#!/usr/bin/python”修改为“#!/usr/bin/python2.6.6-old”
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341