2

I have a problem with changing python version,I'm using centos6 and i need to change the python version from 2.6 to 2.7.

[root@master Downloads]# which python
/usr/bin/python
[root@master Downloads]# which python2.7
/usr/local/bin/python2.7

How can i use python2.7 as default,or change the path of python to 2.7?

deadendtux
  • 63
  • 2
  • 8
  • 2
    Unless you want to cripple your system, you don't. – Ignacio Vazquez-Abrams Jun 22 '13 at 03:15
  • 4
    Consider using virtualenv (and virtualenvwrapper) instead. – Paulo Scardine Jun 22 '13 at 03:55
  • i can't install nltk with 2.7,i need to use 2.7 as default,but many system packages relies on 2.6. – deadendtux Jun 22 '13 at 03:55
  • if i used virtual env,i couldnt connect it with other projects,how can i install nltk module in python2.7 – deadendtux Jun 22 '13 at 03:57
  • 1
    The RPM system and a lot of other basic applications depends on the Python version shipped with the distro, your best shot is virtualenv. You can have virtualenvs based on 2.6 and 2.7 all along without conflicts, use the -p flag. – Paulo Scardine Jun 22 '13 at 03:59
  • You can try compiling python 2.6 yourself and installing it – Paco Jun 22 '13 at 04:07
  • As @IgnacioVazquez-Abrams and Paulo Scardine pointed out, it is *crucial* to leave the original version untouched, otherwise you will break yum (and probably a bunch of other things! On a cluster with CentOS 5 and Python 2.4 (i think), we managed to install Python 2.7 (for non-interactive work) using the [Modules Environment](http://modules.sourceforge.net/). But for a personal system, that's probably a bit of an overkill. – Klaus-Dieter Warzecha Jun 22 '13 at 06:54
  • Thanks all the problem solved i think,now i can use python 2.7!! – deadendtux Jun 22 '13 at 13:42

1 Answers1

1

Now my system is like this:

$ ls -la /usr/bin/python
lrwxrwxrwx. 1 root root 7 Oct  1  2012 /usr/bin/python -> python2
$ ls -la /usr/bin/python2
lrwxrwxrwx. 1 root root 9 Oct  1  2012 /usr/bin/python2 -> python2.7
$ ls -la /usr/bin/python2.7
-rwxr-xr-x. 1 root root 10768 Jul 24  2012 /usr/bin/python2.7

You want to do this I think:

sudo rm /usr/bin/python
sudo ln -s /usr/bin/python2.7 /usr/bin/python

So that /usr/bin/python -> /usr/bin/python2.7

But I can not use yum and update my system as Klaus Warzecha pointed out.

User
  • 14,131
  • 2
  • 40
  • 59