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 
VERSION="19.04 (Disco Dingo)"
PRETTY_NAME="Ubuntu 19.04"
$ 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 '19 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 '19 at 9:09
  • 1

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 you have installed which are dependent on Python 2 by running

apt rdepends python --installed

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

On newer releases such as 20.04, Ubuntu provides two packages:

python-is-python2/focal,focal 2.7.17-4 all
  symlinks /usr/bin/python to the DEPRECATED python2

python-is-python3/focal,focal 3.8.2-4 all
  symlinks /usr/bin/python to python3

As the name suggests the earlier one would make python to invoke python2 and later will invoke python3. If you have no application which is dependent on Python 2, you can install python-is-python3 to make python to invoke python3. Alternatively, you can also edit the shebang of the script to /usr/bin/python3 to make script to directly use python3 as the interpreter.

  • 14
    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 '19 at 19:04
  • 13
    "... 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 '19 at 8:50
  • 8
    @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 '19 at 10:14
  • 2
    @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 '19 at 11:01
  • 5
    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 '19 at 14:35

To my knowledge, only arch linux did it: to call python3 from the default python command. Despite the PEP 394 recommendation.

It can be changed in /usr/bin by redefining the links between python, pythonX and pythonX.Y. But be prepared to cope with a lot of bugs, since all your all python2 scripts will mandate to have an explicit shell bang:

#!/usr/bin/env python2

A shell bang which is seldomly used in old scripts.


I am sharing my realtime experience,

my system is pointing default to python2.7 even though I installed python3.6 in my machine

But when I trying to download new packages for python3.6,But it is downloading with default python2.7

so I came across this pyenv,

I installed the pyenv

after installing

 $ pyenv install --list
 $ pyenv global

pointing to default system(python2.7)

installed python3.6

$ pyenv install 3.6.9

changed from python2.7 to python3.6

$ pyenv global 3.6.9

suppose if you want installed the package related python2.7 then change then python environment

$ pyenv global 2.7.0

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.