New Linux VPS, installing Python and a few other tools I like to use. Did apt-get update and apt-get upgrade, and I noticed when I did apt-get install python it defaulted to version 2.7. (I can, however, do apt-get install python3 to install Python 3)

I was just curious why this wouldn't install Python 3 by default, it seems like would be a natural upgrade, unless this is due to not breaking scripts that are Python based. It is also mentioned when Googling "when was python 3 released" that it was "a major, backwards-incompatible release," so this to me is the most likely reason.

In short, why does apt-get install python install Python 2.7 and not 3? Why is Python 3 not the default version by now (it was released in December 2008)?

  • You can install python 3 with apt-get install python3 and run python 3 scripts with python3 script.py. – To Do Jan 7 '15 at 8:40
  • @ToDo or use alias python='python3' to avoid using python2 accidentialy – LittleByBlue Jan 7 '15 at 13:06
  • That would cause problems with scripts requiring python2. – To Do Jan 7 '15 at 18:18

There are a few reasons:

  • Ubuntu still has Python 2.x scripts
  • You can run Python 2 and Python 3 next to each other without issue, just call the right binary.
  • Python 2.7 will get bugfix and security support until 2020 (and will likely see community support extend even further than that either directly or through other runtimes like Pypy et alii)
  • Switching /usr/bin/python to Python 3 means a lot of Python 2 scripts stop working because they either call that explicitly or #!/usr/bin/env python and not #!/usr/bin/env python2

These things together conspire together to make upgrading the default in Ubuntu a big time sink for to fix an issue that isn't an issue yet. The long support cycle for Python 2.7 means things should just work™ for at least another five years.

Until then, it's not causing conflicts or problems so let it lie. It's just another dependency.

Of course, if you're writing new code, you should probably be looking to Python 3.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.