How To Use Python 2.7 By Default Instead Python 2.6 On CentOS 6.8

Home » CentOS » How To Use Python 2.7 By Default Instead Python 2.6 On CentOS 6.8
CentOS 6 Comments

Hi,

CentOS 6.8 comes with python 2.6. But I want to use python 2.7 to build gstreamer sdk. I have built python 2.7 and installed it into my custom directory. How to set CentOS to use python 2.7 by default instead of python 2.6?

Thanks!

Regards

Andrew

6 thoughts on - How To Use Python 2.7 By Default Instead Python 2.6 On CentOS 6.8

  • Don’t. If you try to swap out the standard python with another one, expect almost everything you hold dear to break.

    jh

  • Hi,

    Thanks for your reply.

    I want to build gstreamer sdk on CentOS by using cerbero, which is of python program and demands python 2.7. How to make CentOS 6.8 choose python 2.7 by default instead of python 2.6, so as to build gstreamer sdk?

    Thanks!

    Regards

    Andrew

    At 2016-07-04 22:25:20, “John Hodrien” wrote:

  • John Hodrien’s reply was done well.

    Such replies are so rarely done well that I thought it worth noting. Often it’s just “Don’t”, “Don’t do that” or “Don’t do that, it’s stupid”.

  • Not a python programmer, so forgive my ignorance.

    On my Fedora system python 2.7 and 3.? peacefully co-exist. And I thought 2.6 and 2.7 did as well.

    The python manpage lists a couple of environment variables related to version.

    Could you have both installed and when building or testing set your environment to the desired version?

    jon

  • You could have used python virtualenv.

    I’m not a python dev and only have vague memories and some short notes on the subject. FYI I have all my python 2.7 packages installed from PUIAS_6_computational repo which had a better selection of python packages at the time:

    python27-2.7.8
    python27-virtualenv-1.10.1

    When you have python27-virtualenv package you can create and activate a virtual environment with the following commands:

    $ mkdir ~/opt/python27
    $ virtualenv-2.7 ~/opt/python27
    $ . ~/opt/python27/bin/activate

    (python27) prefix will be added to the shell prompt and all subsequent python calls will use version from the virtual environment.

    (python27) $ python –version Python 2.7.8

    (python27) $ deactivate

    HTH