天天看點

Python 2.4.3 and Python 2.6.5 on the same RHEL systemhttps://access.redhat.com/solutions/42123

https://access.redhat.com/solutions/42123

 SOLUTION 已驗證 - 已更新 2014年二月7日04:53 - 

English 

環境

  • Red Hat Enterprise Linux (RHEL)
  • Python 2.4.3
  • Python 2.6.5

問題

  • Is possible to have both the python version  2.4.3 (default one used) and version 2.6.5        (available at  http://www.python.org) available on the system?

決議

There are three options, the first is not supported by Red Hat as you need to install a Fedora package . The second one is not supported by Red Hat as you are using one of the third party commercial Python.The third one is fully supported by Red Hat as you are installing  RHEL 6 and includes Python 2.6.5 .

1.  RHEL5 currently ships Python 2.4.3. The fastest way of having Python 2.6 coexisting with Python 2.4 in RHEL5 is installing the already existing EPEL    package for Python 2.6. EPEL (Extra Packages for Enterprise Linux) is a volunteer-based community effort from the Fedora project to create a  repository of high-quality add-on packages for Red Hat Enterprise Linux. Fedora is the upstream of RHEL and add-on packages for EPEL are  primarily sourced from the Fedora repository and built against RHEL.

If you want to pursue the EPEL path, it's very easy to setup. You can  see the details here:  http://download.fedora.redhat.com/pub/epel/5/i386/repoview/epel-release.html

a) Install the EPEL repository in your system. As root:

Raw

# rpm -ivh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
           

b) Then, install the 'python26' package:

Raw

# yum install python26
           

c) If it's the first package from the EPEL repository that you install in the  system, you'll be asked if you want to install the GPG key used to sign  EPEL packages. Just answer 'y' and press Enter:

Raw

warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 217521f6
epel/gpgkey                                              | 1.7 kB     00:00     
Importing GPG key 0x217521F6 "Fedora EPEL <[email protected]>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
Is this ok [y/N]:
           

d) As you can see, the Python 2.6 release is installed with a different  binary name, to avoid changing the behaviour of the multiple RHEL  components that depend on Python 2.4, such as the 'yum' package manager  itself:

Raw

# rpm -qil python26 | grep usr/bin
   /usr/bin/pydoc26
   /usr/bin/python2.6
   /usr/bin/python26
           

e) Now you just need to make sure that you script uses '/usr/bin/python26'  instead of '/usr/bin/python', either replacing the first line of your  script, from:

Raw

#!/usr/bin/env python
           

    to:

Raw

#!/usr/bin/env python26
           

    or just using /usr/bin/python26 instead of /usr/bin/python before the script name when you execute it.

2. Use one of the third party commercial Python distributions suggested  by the Python project, such as ActivePython (  http://www.activestate.com         /activepython ), Enthought Python Distribution ( http://enthought.com/products/epd.php ) or PyIMSL Studio (http://www.vni.com/products            /imsl/pyimslstudio/ ). ActivePython provides and fully supports all the Python versions that they provide on top of RHEL.

While these packages are unsupported by Red Hat, we should explain what unsupported by Red Hat means:

  • We don't mean that your whole system becomes unsupported by the use of these packages.
  • We don't mean that we'll refuse to help you if you have an issue with these packages.
  • If something is broken because of us (a bug or change of a documented or standardized behaviour in RHEL) we'll provide a workaround whenever possible and we'll fix our product.
  • If something is broken within the EPEL package itself, we'll support you as much as comercially reasonable. That means that we'll do our best to help you, but we can not commit that we'll fix the issue, since the package is not provided by us.

     In short, we'll support EPEL packages as we support any third party application running on top of our OS.

3. Use RHEL 6 that includes Python 2.6.5