First step: Download python2.7.4 version Source:
wget http://python.org/ftp/python/2.7.4/Python-2.7.4.tgz
Unzip the file
[Email protected] ~]$ tar jxvf python-2.7.4.tar.bz2
[Email protected] ~]$ CD Python-2.7.4
[[email protected] python-2.7.4]$ ls
Config.guess Configure Demo Grammar install-sh LICENSE Makefile.pre.in Modules Parser pcbuild Python riscos Tools
Config.sub configure.ac Doc Include Lib Mac Misc Objects PC pyconfig.h.in README setup.py
[email protected] python-2.7.4]$ Su-
Password:
[Email protected] ~]# mkdir/usr/local/python2.7.4
[Email protected] ~]# cd/home/
[Email protected] home]# CD niuxl/python-2.7.4
[[email protected] python-2.7.4]# ls
Config.guess Configure Demo Grammar install-sh LICENSE Makefile.pre.in Modules Parser pcbuild Python riscos Tools
Config.sub configure.ac Doc Include Lib Mac Misc Objects PC pyconfig.h.in README setup.py
Before compiling, you need to install the Zlib package first:
[email protected] python-2.7.4]# Yum install zlib zlib-devel
[Email protected] python-2.7.4]#./configure--prefix=/usr/local/python2.7.4
Checking build system Type ... I686-pc-linux-gnu
Checking host system Type ... I686-pc-linux-gnu
Checking for--enable-universalsdk ... no
Checking for--with-universal-archs ... 32-bit
Checking MACHDEP ... linux2
Checking Extraplatdir ...
Checking for--WITHOUT-GCC ... no
Checking for gcc ... no
Checking for cc ... No
Checking for cl.exe ... no
Configure:error:in '/home/niuxl/python-2.7.4 ':
Configure:error:no acceptable C compiler found in $PATH
Missing C Editor
To install the C editor:
[[email protected] python-2.7.4]# Yum install gcc
.. Slightly
Note: There is a choice of Y and n places, prompts whether to continue to download, enter Y, return!
GCC installation Complete
Continue compiling Python
[Email protected] python-2.7.4]#./configure--prefix=/usr/local/python2.7.4
.. Slightly
OK compilation succeeded
[[email protected] python-2.7.4]# make&& make install
Installation Successful
[Email protected] python-2.7.4]# python-v
Python 2.4.3
The current version remains 2.4.3, and now begins to upgrade Python,
View the directory where the python command resides
[[email protected] python-2.7.4]# Whereis Python
Python:/usr/bin/python2.4/usr/bin/python/usr/lib/python2.4/usr/include/python2.4/usr/share/man/man1/ Python.1.gz
Modify the soft connection of the/usr/bin/python to python2.4.3
[Email protected] python-2.7.4]# mv/usr/bin/python/usr/bin/python2.4.3
[[email protected] python-2.7.4]# Python
-bash:/usr/bin/python: No file or directory
The python command cannot be found, just add the version python2.7.4 command to the environment variable!
Mode 1:
Modify/etc/profile Add the following two lines:
Path= $PATH:/usr/local/python2.7.4/bin
Export PATH
And then
[Email protected] python-2.7.4]# Source/etc/profile
[Email protected] python-2.7.4]# python-v
Python 2.7.4
Of course, you can also create a soft connection for 2.7.4 version of Python:/usr/bin/python
[Email protected] ~]# ln-s/usr/local/python2.7.4/bin/python/usr/bin/python
Also
Ok,python Upgrade Complete
So far, the last thing you need to do is the compatibility of Yum with Python:
[Email protected] pipe]# Vi/usr/bin/yum
#!/usr/bin/python
The first line is revised to read
#!/usr/bin/python2.4.3 (that is, the original Python changed name)
Upgrade Linux default Python to 2.7.4 version