1

I have Python 2.6.6 installed by default on a Debian machine. To get the default python version, I've used :

python -V

I've also installed python 2.7.5 but the default python interpreter is still the old version.

I know that I can use the python2.7 command to run my scripts, but I want to directly run my script like this:

app.py

And I guess the default interpreter will be used.

How can I switch to the newest version of python ?

Ghilas BELHADJ
  • 13,412
  • 10
  • 59
  • 99
  • @sandman I've seen this, there is no agreed solution, and the most voted up doesn't work for me – Ghilas BELHADJ Aug 17 '13 at 08:16
  • I realized that. Have you tried the command update-alternatives. Here's a pointer to that. I myself didn't know of this command's existence until a few weeks ago. http://askubuntu.com/questions/14615/how-do-i-make-the-terminal-run-python-3-1. Look at the second answer to this question. I am not saying it will work. I am just pointing to this in case you haven't seen this before. If you have, feel free to let me know and I will delete this comment. – Sandman Aug 17 '13 at 08:18
  • The other question not only lacks an accepted answer, but also is significantly different from this one. Note that it concerns CentOS /usr/local/bin/python while this one concerns Debian's /usr/bin/python, which is managed differently and has significantly different system impact if changed. – ʇsәɹoɈ Aug 18 '13 at 06:35

1 Answers1

3

The /usr/bin/python symlink is created by the python-minimal package. In debian 6 (squeeze), that package links it to python2.6. Your most reasonable options are to overwrite the symlink with one pointing to python2.7, install a newer python-minimal package built for your distro from the version 2.7 package sources*, or upgrade to debian 7 (wheezy).

*If you choose the second option, you'll have to deal with the corresponding package dependencies as well, which might be a hassle depending on how your python2.7 binaries are installed.

Also note that debian does not use the alternatives system to manage the symlink in question, so trying to use update-alternatives here is likely to cause problems in the long run, if it works at all.

ʇsәɹoɈ
  • 22,757
  • 7
  • 55
  • 61