说明:默认的Linux操作系统上的Python版本在2.6,个别的Python程序无法执行,需要升级Python版本到2.7
方法:我们采用源码安装Python2.7
步骤:
1)先下载Python的tar包到目录/usr/local/src/下面:
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
2)解压tar包:
tar -zxvf Python-2.7.3.tgz
3)在/usr/local/下面建立文件python27
mkdir python27
4)编译安装Python
cd /usr/local/src/Python-2.7.3
./configure --prefix=/usr/local/python27
make
make install
5)将原来的python备份
cd /usr/bin/
mv python python.bak
6)创建软连接:
ln -s /usr/local/python27/bin/python2.7 /usr/bin/python
7)检测
python
8)出现Python版本信息
Python 2.7.3 (default, Aug 19 2016, 13:16:22)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>