6

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)?

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

1 Answer 1

13

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.

4
  • 3
    Well thought out answer Oli. I might add a little bit of because the PEP tells us it's the right thing to do. It's more intuitive for a package/pseudo-package to refer to the binary it provides. Jan 7, 2015 at 10:44
  • 1
    Other distributions already performed that step. It's only Ubuntu/Debian that see this as a "time sink" while others moved on and made things better.
    – Nowaker
    Apr 5, 2018 at 16:12
  • Unfortunately this question remains relevant 4y8m later. It is time to move on. This answer is from 2007, and postpone mentality won't get us any further. See hackaday.com/2018/08/15/… , theregister.co.uk/2019/09/09/the_end_of_python_2_2020 and specially this python3statement.org/practicalities
    – DrBeco
    Sep 9, 2019 at 19:59
  • >You can run Python 2 and Python 3 next to each other without issue, just call the right binary. Generally, not the case. If you have no power over which binary is run or if you change the default binary, then automatic updates/installations and other interactions with Python might straight up break.
    – Akito
    May 15, 2022 at 12:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .