0

I have installed python 2.7.5 on CentOS 6.4 which python 2.6 already installed.

Python2.7 is under /usr/local/bin and library configuration is correct as well.

I set alias in .bash_profile as

alias python='/usr/local/bin/python2.7'
PATH=$PATH:/usr/local/bin

However, I need to do source .bash_profile each time I logged in and it's pretty annoying. How can I change my default python version to python2.7.5?

Thanks

brsbilgic
  • 11,613
  • 16
  • 64
  • 94

2 Answers2

0

Logout from desktop environment, then login. And it will work. (.bash_profile is not sourced when you login graphically.)

If that does not work put alias line to .bashrc.

falsetru
  • 357,413
  • 63
  • 732
  • 636
-1

Create a symbolic link python in /usr/bin and point it to /usr/local/bin/python2.7. Something like this should work:

ln -s /usr/local/bin/python2.7 /usr/bin/python

Make sure you have permissions to do that. Once done, hit python command and it should get you to python 2.7

Hope this helps.

Rahul Tanwani
  • 441
  • 3
  • 10
  • 1
    Because some tools are dependent on default version of python, overwriting /usr/bin/python will break those tools. – falsetru Jul 14 '13 at 16:59
  • I believe python 2.7 is completely backward compatible with python2.6 and below (unlike 3.x). – Rahul Tanwani Jul 14 '13 at 18:00
  • If dependent module is pure python, it will be run in Python 2.7. But if it is extension module, it will not. – falsetru Jul 14 '13 at 18:04
  • Enen though the module is pure python, there could be problem. Imagine that there was some script name /usr/bin/abc which import module xyz. Module xyz is not installed for Python2.7, only for Python2.6 unless you manually install such modules. (/usr/lib/python2.6/site-packages/xyz/....) – falsetru Jul 14 '13 at 18:09
  • See [this question](http://stackoverflow.com/questions/10624511/upgrade-python-without-breaking-yum). – falsetru Jul 14 '13 at 18:11
  • I agree with this. :) – Rahul Tanwani Jul 14 '13 at 18:16