RedHat upgrade Python to 2.7.6

Source: Internet
Author: User
Start learning Python today! I checked the python in the RedHat Vm and found that it was still native 2.4.3. So I decided to upgrade [root @ linuxidc ~]. # PythonPython2.4.3 (#1, May52011, 16:39:10) [GCC4.1.220080704 (RedHat4.1.2-50)] onlinux2Type "help", "c

Start learning Python today! I checked python in the RedHat Vm and found that it was still native 2.4.3. So I decided to upgrade it.

[Root @ linuxidc ~] # Python
Python 2.4.3 (#1, May 5 2011, 16:39:10)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
[Root @ linuxidc ~] #

1. download the latest version of python z.

[Root @ linuxidc ~] # Wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tgz

2. decompress and compile

[Root @ linuxidc ~] # Tar xvf Python-2.7.2.tar.bz2
[Root @ linuxidc Python-2.7.6] #./configure -- prefix =/usr/local/python27
[Root @ linuxidc Python-2.7.6] # make
[Root @ linuxidc Python-2.7.6] # make install

[Root @ linuxidc Python-2.7.6] # ls/usr/local/python27/-al
Total 28
Drwxr-xr-x 6 root 4096 Mar 21 0:01.
Drwxr-xr-x 13 root 4096 Mar 21 ..
Drwxr-xr-x 2 root 4096 Mar 21 0:01 bin
Drwxr-xr-x 3 root 4096 Mar 21 0:01 include
Drwxr-xr-x 4 root 4096 Mar 21 0:01 lib
Drwxr-xr-x 3 root 4096 Mar 21 0:01 share

3. overwrite the original python Link

[Root @ linuxidc Python-2.7.6] # mv/usr/bin/python/usr/bin/python_old
[Root @ linuxidc Python-2.7.6] # ln-s/usr/local/python27/bin/python/usr/bin/
[Root @ linuxidc Python-2.7.6] # python
Python 2.7.6 (default, Mar 21 2014, 01:00:09)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

Now you can use python2.7 normally, but yum is used in version 2.4. If you enter yum, an error is returned.

[Root @ linuxidc Python-2.7.6] # yum
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

Please install a package which provides this module, or
Verify that the module is installed correctly.

It's possible that the above module doesn't match
Current version of Python, which is:
2.7.6 (default, Mar 21 2014, 01:00:09)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)]

If you cannot solve this problem yourself, please go
The yum faq:
Http://wiki.linux.duke.edu/YumFaq

5. Modify yum

[Root @ linuxidc Python-2.7.6] # vim/usr/bin/yum

#! /Usr/bin/python # modify the location to 2.4

[Root @ linuxidc Python-2.7.6] # vim/usr/bin/yum

#! /Usr/bin/python2.4

Yum can be used!

[Root @ linuxidc Python-2.7.6] # yum
Loaded plugins: rhnplugin, security
You need to give some command
Usage: yum [options] COMMAND

List of Commands:

Check-update Check for available package updates
Clean Remove cached data
Deplist List a package's dependencies
Erase Remove a package or packages from your system
Groupinfo Display details about a package group
Groupinstall Install the packages in a group on your system
Grouplist List available package groups
Groupremove Remove the packages in a group from your system
Help Display a helpful usage message
Info Display details about a package or group of packages
Info-security Returns security data for the packages listed, that affects your system
Install Install a package or packages on your system
List List a package or groups of packages
List-security Returns security data for the packages listed, that affects your system
Localinstall Install a local RPM
Makecache Generate the metadata cache
Provides Find what package provides the given value
Reinstall a package
Repolist Display the configured software repositories
Resolvedep Determine which package provides the given dependency
Search Search package details for the given string
Shell Run an interactive yum shell
Update Update a package or packages on your system
Update-minimal Works like update, but goes to the 'newest 'package match which fixes a problem that affects your system
Upgrade Update packages taking obsoletes into account


Options:
-H, -- help show this help message and exit
-T, -- tolerant be tolerant of errors
-C run entirely from cache, don't update cache
-C [config file] config file location
-R [minutes] maximum command wait time
-D [debug level] debugging output level
-- Showduplicates show duplicates, in repos, in list/search commands
-E [error level] error output level
-Q, -- quiet operation
-V, -- verbose operation
-Y answer yes for all questions
-- Version show Yum version and exit
-- Installroot = [path] set install root
-- Enablerepo = [repo] enable one or more repositories (wildcards allowed)
-- Disablerepo = [repo] disable one or more repositories (wildcards allowed)
-X [package], -- exclude = [package]
Exclude package (s) by name or glob
-- Disableexcludes = [repo]
Disable exclude from main, for a repo or
Everything
-- Obsoletes enable obsoletes processing during updates
-- Noplugins disable Yum plugins
-- Nogpgcheck disable gpg signature checking
-- Disableplugin = [plugin]
Disable plugins by name
-- Enableplugin = [plugin]
Enable plugins by name
-- Skip-broken skip packages with depsolving problems
-- Security Include security relevant packages
-- Cve = CVE Include packages needed to fix the given CVE
-- Bz = BZ Include packages needed to fix the given BZ
-- Advisory = ADVISORY Include packages needed to fix the given advisory
[Root @ linuxidc Python-2.7.6] #

Python details: Click here
Python: Click here

Recommended reading:

(Zhou Wei, Zong Jie). [hd PDF scan version + book with video + code] http://www.linuxidc.com/Linux/2013-11/92693.htm

Python script to get Linux information http://www.linuxidc.com/Linux/2013-08/88531.htm

For more information about RedHat, see RedHat topic page http://www.linuxidc.com/topicnews.aspx? Tid = 10

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.