First off, you shouldn't just blindly have Python 2 on Linux. A lot of distributions these days don't need it and only install it for compatibility reasons. If the OS came pre-installed with it, keep it, but otherwise, don't go out of your way to install it unless you have some software that actually needs it. Some Linux systems don't even have it by default anymore (Arch for example).
Beyond that, as suggested in the comments, only install what versions you actually need. In other words, if you have no software using Python version X.Y, and the OS didn't automatically install it, don't have it installed on your system. This advice applies in general to almost any programming language though. More code translates to more possibilities for an attacker to exploit a bug.
Building on this advice with a real-world example:
On my Gentoo systems, I currently have Python 2.7, 3.6, and 3.7.
- I need Python 2.7 because I have a few packages that require AsciiDoc for their documentation, and that only works with Python 2.7.
- I need Python 3.6 because that's the primary version supported by almost all other code on my system (and in fact, by most of the Python related packages in Gentoo right now).
- I need Python 3.7 for new development work and testing purposes.
I could in theory also have Python 3.4 and 3.5 installed on these systems, but I don't because I have exactly zero software that needs either of them.
You should have those versions that you are using; You should not use python 2 without necessity as it is obsolete and going to be completely retired according to Python core team in 2020, so if it's not requirement - use python 3 – Drako – 2018-08-06T15:00:36.567
Note that at least on Ubuntu, the setup uses Python2 AND Python3 for important portions of the system tools (e.g. apt). Try to remove Python2 OR Python3 and you have a complete mess. – Hannu – 2018-08-06T18:36:57.757