6

I am new to Linux and going through my installed folder I can see there are four different Python folders in the directory list.

python python2.7 python3 python3.2

Do we need all the four versions or should I remove the others and keep only the latest?

Also don't the older versions get removed automatically when newer versions are installed as in Windows?

6
  • What distro and what is the path? Some applications still depend on python2.7 so be wary about deleting that.
    – Jivings
    Commented Oct 9, 2012 at 22:08
  • I am using debian and the path is /etc
    – SteveIrwin
    Commented Oct 9, 2012 at 22:59
  • 4
    /etc is not the install path for applications. It's where configuration is stored. Don't mess with the stuff in there.
    – Jivings
    Commented Oct 9, 2012 at 23:03
  • One reason for the multiple versions is that version 3 introduced some non backward compatible changes and broke some existing functionality. Commented Oct 9, 2012 at 23:10
  • I want to remove it because it takes up a lot of space on the SD cards and backups. One of these days I'll set up a sacrificial system and remove it just to see the difference in space usage and whether or not it breaks anything.
    – SDsolar
    Commented Aug 16, 2017 at 21:08

4 Answers 4

8

If you look in /usr/bin, there are actually only two versions installed:

$ ls -la /usr/bin/python*
lrwxrwxrwx 1 root root       9 Jun  5 23:08 /usr/bin/python -> python2.7
-rwxr-xr-x 1 root root 2679344 May  6 19:31 /usr/bin/python2.7
lrwxrwxrwx 1 root root       9 Aug  2 18:04 /usr/bin/python3 -> python3.2
lrwxrwxrwx 1 root root      11 Jul  6 09:52 /usr/bin/python3.2 -> python3.2mu
-rwxr-xr-x 1 root root 2612900 Jul  6 09:52 /usr/bin/python3.2mu
lrwxrwxrwx 1 root root      11 Aug  2 18:04 /usr/bin/python3mu -> python3.2mu

The entries marked l at the start are links; they're just pointers to executable files.

As has already been said, you need both versions and don't mess with stuff in there ...

5
  • What's the mu on python3.2mu? Commented Oct 10, 2012 at 6:51
  • @AlexChamberlain - According to pep-3149 the m shows that it was compiled with the --with-pymalloc flag, while the u shows that it was compiled with the --with-wide-unicode flag.
    – Mark Booth
    Commented Oct 10, 2012 at 9:34
  • @scruss - For completeness, you may want to mention that the l entries are symbolic links.
    – Mark Booth
    Commented Oct 10, 2012 at 9:37
  • @MarkBooth, yeah, I said that in the original answer
    – scruss
    Commented Aug 16, 2017 at 21:28
  • 1
    Nope, original answer Oct 10 '12 at 0:03, my comment was at 9:37 and your edit was at 11:33. You could have just flagged my comment as obsolete.
    – Mark Booth
    Commented Aug 16, 2017 at 22:56
3

Python 3 is a backward incompatible upgrade of the language. As already mentioned, so much was changed, that most programs won't work on Python 3 without modifications. Even worse, many Python libraries are not compatible with Python 3 yet.

This is why at least two versions are needed - legacy Python 2.x and new Python 3.x. This is exactly what you have on Debian systems. You have 4 different paths you can use to run Python:

  • python2.7 - it's version 2.7 of Python, the newest version of 2.x line.
  • python3.2 - it's version 3.2 of Python, the newest version of 3.x line available in Debian (3.3 is not yet available).
  • python - it's a default python interpreter. It's a symbolic link to some version that is considered default one. Currently - in Debian - it's still Python 2 so it points to 2.7.
  • python3 - it's the most up to date Python 3 interpreter available in Debian. Currently it symlinks to a 3.2 version of interpreter.

Conclusion

A lot of packages depend on Python 2.x so you should not remove it. There may be some packages that depend on Python 3.x so you also probably don't want to remove this one.

1
  • I know that is true about Python 2.7 but am not aware of anything that fails if Python 3 is removed. I feel an experiment coming on. It would be nice to have smaller full rsync backups if possible.
    – SDsolar
    Commented Aug 16, 2017 at 21:10
2

Python3 isn't really an upgrade of Python2. Only trivial programs will run without at least being run through 2to3.

On the other hand, when there are minor updates, eg 2.7.2 -> 2.7.3 the 2.7 will be updated to the new version and the older one gets deleted. This is generally ok as there isn't supposed to be backward incompatible changes (I won't say this has never happened though)

You won't usually see say 3.3 being added to the repository between releases, but when it does show up and you upgrade, the 3.2 will remain installed in case you depend on that specific version. Pure Python code that runs on 3.2 should be mostly ok on 3.3, but C libraries may not work without being rebuilt.

0
0

The answer to the last part of your question, "Also don't the older versions get removed automatically when newer versions are installed as in Windows?"

The answer is a clear and emphatic No.

Older versions do not get removed when new versions are installed.

Too much of our software ecosystem has been built on top of Python 2.x for it to be expendable. To remove it would break a lot of our commands.

Plus, Python 3 offers very little that is attractive to the Python 2.7 programmer. If you find you need those features then you have the option of using Python3. If not, people like me will stay with Python 2.x

As has been mentioned in the other answers, they are not really the same language anymore.

It is like the difference between programs that could work with Windows 98 but couldn't work on Windows 2000. Programs that you used under Win98 had to be re-released after being compiled for 2000 (32 bit). Windows 2000 did not catch on in the consumer market because it would cause those consumers to need to buy their favorite products again. Only with Windows XP did they finally make it so programs of both types could run under the same Windows OS. We are fortunate that Microsoft has learned from that lesson and that 32-bit and 64-bit programs can both be run on any modern version of Windows.

Back to the question in your title, "Do we need multiple versions of Python?" - it depends on what software you want to be able to use. One standout example is flightgear. Without Python3 it will not run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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