Contos replacing the Python version

Source: Internet
Author: User
Tags install openssl

1. View version

#python-V
Python 2.6.6


2, pre-installation, installation of the relevant library
#yum install gcc gcc-c++ autoconf automake
#yum Install OpenSSL Openssl-devel


3. Download and install
#wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
#tar-xvzf python-2.7.11.tgz
#cd Python-2.7.11
#./configure--prefix=/usr/local/python2.7
#make
#make Install


4. Modify the Python link to point to
#mv/usr/bin/python/usr/bin/python2.6.6.old
#ln-S/usr/local/python2.7/bin/python/usr/bin/python

(L is L, do not write in)

View version
# python-v
Python 2.7.11


5. Modify the Python version used by Yum
Although Python is now installed, there are problems with the Yum command--yum not working properly:


# Yum List
There was a problem importing one of the Python modules
Required to run Yum. The error leading to this problem was:

No module named Yum

Install a package which provides this module, or
Verify the module is installed correctly.

It ' s possible that the above module doesn ' t match the
Current version of Python, which is:
2.7.11 (default, 17 2016, 23:54:43)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]

If You cannot solve this problem yourself and go to
The Yum FAQ at:
Http://yum.baseurl.org/wiki/Faq

This is because the Python version that Yum uses by default is 2.6.6, and the current version of Python is 2.7.11, so the problem is that it just needs to be the default Python configuration version of Yum:


#vi/usr/bin/yum

Change the #!/usr/bin/python of the file header to

#!/usr/bin/python2.6

6. Modify Environment variables

$vim ~/.bash_profile

Modified to:

Python_home=/usr/local/python2.7

PATH=$PATH:$HOME/bin:$PYTHON _home/bin

$source. Bash_profile

Contos replacing the Python version

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.