Python在CentOS上编译安装
CentOS 7
1.* 安装前准备
1.*.& 下载安装包
点击查看代码
$ yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget
1.*.& 下载Python 2.6版本
点击查看代码
$ wget https://www.python.org/ftp/python/2.6.8/Python-2.6.8.tgz
1.*.& 解压
点击查看代码
$ tar zxf Python-2.6.8.tgz
1.*.& 配置安装信息
点击查看代码
$ cd Python-2.6.8 && ./configure --prefix=/usr/local
$ make
如果安装错误的话:
点击查看代码
[root@localhost Python-2.6.8]# ./configure --prefix=/usr/local
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... linux3
checking EXTRAPLATDIR...
checking machine type as reported by uname -m... x86_64
checking for --without-gcc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/opt/Python-2.6.8':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
由于本机缺少gcc编译环境
1、通过yum安装gcc编译环境:yum install -y gcc
2、本机没有安装yum功能,可下载gcc安装包:https://gcc.gnu.org/
1.* 安装
点击查看代码
$ make altinstall # 使用altinstall安装,不影响其他Python版本
1.* 创建链接
点击查看代码
$ ln -s /usr/local/bin/python2.6 /usr/bin/python # 切换版本,但是每次都需要先删除一下/usr/bin/python