在Linux系统CentOS 6.8上安装Python 2.7.13

CentOS 6.6自带的是Python 2.6.6,而编译llvm需要Python 2.7以上。

20170213161717

下载Python-2.7.13.tar.xz的源代码自己编译安装。

操作步骤如下:

1)安装devtoolset
yum groupinstall “Development tools”

2)安装编译Python需要的包包
yum install zlib-devel
yum install bzip2-devel
yum install openssl-devel
yum install ncurses-devel
yum install sqlite-devel

3)下载并解压Python 2.7.13的源代码
cd /opt
wget –no-check-certificate https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz
tar xf 2.7.13.tar.xz

tar解压出现提示:xz: Cannot exec: No such file or directory 解决方法:安装xz软件包 yum install xz -y

4)编译与安装Python 2.7.13
cd Python-2.7.13
./configure –prefix=/usr/local
make && make install

5)将python命令指向Python 2.7.13
ln -s /usr/local/bin/python2.7 /usr/local/bin/python

6)检查Python版本
sh
sh-4.1# python -V
Python 2.7.13

7 )安装easy_install
wget -q http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py

如果出现错误:urllib2.URLError: <urlopen error unknown url type: https>
安装openssl,openssl-devel
yum install openssl
yum install openssl-devel

【参考资料】
Installing python 2.7 on centos 6.3 https://github.com/h2oai/h2o/wiki/Installing-python-2.7-on-centos-6.3.-Follow-this-sequence-exactly-for-centos-machine-only

未经允许不得转载:Ppabc博客 » 在Linux系统CentOS 6.8上安装Python 2.7.13