背景介绍:
centos6.5系统本省自带了Python2.6, 而此系统上同时有需要Python2.7版本。
如何成功安装python另一版本2.7,通过网上资料查询,总结如下:
Note:
1. centos6.5版本装好后,一些相关的依赖包需要安装,这是安装python2.7的前提依赖项
2. 以下总结几乎可以绕开安装中出现的各式问题
Installing Python 2.7.8 on CentOS 6.5
1. UpdateCentOS and install development tools
1.1 yum-y update
1.2 yumgroupinstall -y 'development tools'
2. Installthe packages
2.1 yuminstall -y zlib-devel bzip2-devel openssl-devel xz-libs wget
3. Install Python2.7.8 from source
3.1 http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
3.2 xz -d Python-2.7.8.tar.xz
3.3 tar -xvf Python-2.7.8.tar
3.4 cd Python-2.7.8
3.5 ./configure --prefix=/usr/local
3.6 Make
Note: If failed, please referto “Make commanderror”
3.7 make altinstall
4. Create symbolic link forPython2.8
4.1 Check the python version onCentOS 6.5 as follows
[root@localhostbin]# which python
/usr/bin/python
[root@localhostbin]# which python2.7
/usr/local/bin/python2.7
4.2 Check PATH asfollows
[root@localhost bin]# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/tianxia/bin
Ensure ‘/usr/local/bin’(python2.7) is prior to ‘/usr/bin’ (python).
4.3 Create symboliclink
4.3.1 cd /usr/local/bin
4.3.2 ln –s Python2.8 python
4.4 Check thedefault python version
[root@localhostbin]# which python
/usr/local/bin/python
[root@localhostbin]# python
Python 2.7.8(default, Jul 16 2015, 01:36:52)
[GCC 4.4.7 20120313(Red Hat 4.4.7-11)] on linux2
Type"help", "copyright", "credits" or"license" for more information.
>>>
5. Install Python tool
5.1 Install setuptools
5.1.1 wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4
5.1.2 tar-xvf setuptools-1.4.2.tar.gz
5.1.3 cdsetuptools-1.4.2
5.1.4 python2.7setup.py install
5.2 Install pip
5.2.1 curlhttps://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py |python2.7 -
5.3 Installvirtualenv
5.3.1 pip2.7 install virtualenv
Make command error:
“make” command runs severalhours, (there are much “checking for… ” information on the screen),please ensure system time iscorrect.
If not, please run command justlike:
“data –s2015-**-** 00:00:00”
Reference
1. http://bicofino.io/blog/2014/01/16/installing-python-2-dot-7-6-on-centos-6-dot-5/
2. https://www.digitalocean.com/community/tutorials/how-to-set-up-python-2-7-6-and-3-3-3-on-centos-6-4