CentOS6.5 upgrade to Python version 2.7

  • 2020-05-17 07:25:18
  • OfStack

CentOS 6.5 upgrade Python version 2.7

The profile

Python-2.6.6 was pre-installed in CentOS 6.5, and the new Python-2.7.9 (pre-installed version of CentOS 7) mainly differs from Python in that the new version of Python introduces richer module functions. For starters, this may not be a big deal, but these new modules are relatively indispensable in certain compilation environments. For example, Devstack all-in-one mode is used to install OpenStack development and debugging platform, which requires Python-2.7 or above support, which can save a lot of trouble of missing modules.

- software preparation
- Python 2.7.9
- ipython-0.12.1
- system preparation

CentOS 6.5

Install Python - 2.7.9

1. View Python Version of the current system


[root@jmilk ~]# python --version
Python 2.6.6

2. Download Python - 2.7.9


wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz

3. Install Python

Extract a.


tar -Jxvf Python-2.7.9.tar.xz -C /usr/src/ 

Installed b.


mkdir /usr/local/python27 
cd /usr/src/Python-2.7.9/ 
./configure --prefix=/usr/local/python27 && make && make install 

c. Point the system python directive to Python-2.7.9 by default

YUM in CentOS6.5 requires support of Python-2.6.6, so it is not recommended to uninstall the old version.


mv /usr/bin/python /usr/bin/python266 
ln -s /usr/local/python27/bin/python2.7 /usr/bin/python 
python --version 

Solve the compatibility problem between YUM and Python2.7.9

Because YUM needs the support of python-2.6.6, YUM in CentOS 6.5 is not compatible with Python-2.7, resulting in the unavailability of YUM. You need to repoint YUM to the Python-2.6.6 executable in the YUM configuration file (CentOS 6.5 original /usr/bin/python program)


vim /usr/bin/yum
 Will the original: 
# ! /usr/bin/python
 To: 
#!/usr/bin/python266

1 generally speaking, this can restore the use of YUM, and all software that is not compatible with Python-2.7 in CentOS 6.5 can use the above method.

If you still cannot execute the YUN instruction after the above steps, try the following solution.

Copy the installation CD of CentOS 6.5 or the following rpm package (version dependent) in the ISO file to the system directory.


mount /dev/cdrom /mnt/cdrom

cd /mnt/cdrom/Packages
cp yum-3.2.29-40.el6.centos.noarch.rpm \
python-2.6.6-51.el6.x86_64.rpm \
python-urlgrabber-3.9.1-9.el6.noarch.rpm \
python-devel-2.6.6-51.el6.x86_64.rpm \
python-libs-2.6.6-51.el6.x86_64.rpm /usr/local/python27
cd /usr/local/python27
rpm -Uvh --replacepkgs *.rpm

Installing all the dependencies above might solve this problem.

At this point, the Python upgrade is complete.

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: