24

According to official documentation of Python, Python2.7 support will end near in future.

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support

Why is Ubuntu not using Python3 as default in their upcoming version?

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="19.04 (Disco Dingo)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 19.04"
VERSION_ID="19.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=disco
UBUNTU_CODENAME=disco
$ python
Python 2.7.16 (default, Apr  6 2019, 01:42:57) 
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
  • 2
    You can install the python3.7 package. The problem is that within an ubuntu\ linux mint version there are sometimes still old softwares, so you have to install the newer packages manually. – enigma Aug 13 at 8:59
  • 8
    @enigma It's not a duplicate of that question because python3 is already installed on ラビナンダン's system by default so he has both python and python3 installed alongside each other. – karel Aug 13 at 9:09
37

According to the release notes of Bionic Beaver:

Python 2 is no longer installed by default. Python 3 has been updated to 3.6. This is the last LTS release to include Python 2 in main.

And the above statement is true. Python 2 isn't installed by default in 18.04 and versions released after that. Ubuntu has already moved almost all of its projects from Python 2 to Python 3. For example, according to release notes of Disco Dingo:

Samba was updated to version 4.10.x, and one of the big changes here is python3 support. In Disco, samba and its dependencies are all python3 only now, with the exception of tdb. tdb still builds a python2 package, namely python-tdb, but all the others, including samba itself, are python3 only.

Moreover, even before the release of Ubuntu 18.04, Ubuntu/Canonical started asking developers to move to Python 3 because the end is near. From Python - Ubuntu Wiki:

All Ubuntu/Canonical driven development should be targeting Python 3 right now, and all new code should be Python 3-only. If you can't do this because of your dependency stack, let's talk.

It seems that on your system Python 2 was installed intentionally or may be as a dependency of some other package whose developer haven't moved to Python 3. You can check the packages which are dependent on Python 2 by running,

apt rdepends python

The reason why Python 2 is invoked when python is run lies in the one of the historical point of PEP 394 -- The "python" Command on Unix-Like Systems:

The python command should always invoke Python 2 (to prevent hard-to-diagnose errors when Python 2 code is run on Python 3).

  • 12
    To clarify the final point, Python 3 is not backwards compatible with Python 2. That, and combined with the fact that Python 2 has more library support than Python 3, means that a large number of developers still have a direct dependency on Python 2. Python 3 has been out for a while now, but really it's the libraries that are the reason why Python 2 is still so strongly used, even though it shouldn't even be supported anymore (if I'm remembering correctly, official support ended in 2018). EDIT: official support ends in 2020. – searchengine27 Aug 13 at 19:04
  • 7
    "... the fact that Python 2 has more library support than Python 3 ..." - Do you have a source for that? I rarely encounter libraries anymore that don't support Python 3, and in fact some are dropping support for Python 2! (For example, Django, a popular Python web framework, hasn't supported Python 2 for three releases.) Your statement made sense five years ago, but today I don't think you can make that sweeping generalization without backing it up with statistics. – marcelm Aug 14 at 8:50
  • 7
    @searchengine27 I don't think that library support factors into it. The backwards compatibility concern is that the world is awash with random scripts that start with #!/usr/bin/python or equivalent, which would break if python became python3, whereas random scripts that depend on Python 3 are more likely to start with #!/usr/bin/python3. – James_pic Aug 14 at 10:14
  • 1
    @searchengine27 A long time ago someone made a "Python3 wall of Shame" website that listed the most common dependencies and their python3 status (which at the time was abysmal). However it's been years now that it has been changed to Python 3 Wall of Superpowers since practically all common dependencies have been migrated and the few that weren't migrating are dead anyway (the website hasn't been updated since april 2018 since now basically everything is python3-able). – Giacomo Alzetta Aug 14 at 11:01
  • 4
    Just as an addition: the fact that the Python Software Foundation will stop maintaining Python 2 in 2020 does not mean that Canonical will stop maintaining Python 2 in 2020. In fact, the whole point of using a Linux distribution from a reputable vendor is that all packages in the distribution (for Debian/Ubuntu that means the "main" repository) will be maintained for the entire lifetime of the distribution release regardless of support status of the original upstream package. In other words, the Python 2 package in Ubuntu 19.04 will be maintained as long as Ubuntu 19.04 is. – Jörg W Mittag Aug 14 at 14:35

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.