1

I am quite new with Ubuntu. I have Ubuntu 18.04.04 In the terminal, python --version returns Python 2.7.17.

But, I have installed Spyder with the Ubuntu Software Center. When I run Spyder the version is 3.6

Why I have two versions? And,can I remove version 2.7? How?

1
  • 3
    Don't remove any python. You'll totally break the system. And don't change default python setting. You are warned now!
    – Pilot6
    Feb 16 '20 at 18:30
3

You have two versions because 18.04 happened to be in the middle of Ubuntu's conversion from Py2 to Py3. So you have both versions on your system. Newer releases have only Python3.

DO NOT remove the default versions of Py2 and Py3 provided with Ubuntu 16.04 or 18.04. Doing so will break your system quite horribly.

On Ubuntu 19.10 and newer, Py2 is no longer included with the default install of Ubuntu, and is no longer in the -main pocket of the Ubuntu repository. It's still in the repositories (moved to -universe), and some -universe and -multiverse packages still depend upon Py2...but they are not part of a new install.

7
  • 2
    On Ubuntu 19.10 and newer, Py2 is no longer included with the default install of Ubuntu. Are you sure?
    – FedKad
    Feb 16 '20 at 19:07
  • as far as I know, there are still a lot of packages that will pull in phyton 2 stuff. This is on 20.04 development version, where I have 2 test servers, one that is now polluted, due to needing some things. On the other, i have not allowed python 2 to be pulled in due to dependencies. Pyhton 2 elimination has been a challenge. Feb 16 '20 at 19:15
  • Edited the final paragraph to clarify. The Py2-to-Py3 conversion of -main (the packages used in a stock install) has been complete for over a year. Many packages in -universe and -multiverse do indeed depend upon Py2...but that's not relevant to the OP's question: You CAN remove Py2 in 19.10 and newer without destroying apt and other essential services.
    – user535733
    Feb 16 '20 at 19:28
  • @DougSmythies I just started Python development in Ubuntu and make my code both Python 2 & 3 compatible along with Gnome 3.18 and 3.22 compatible. I'd like the same python program to run Ubuntu 16.04 to Ubuntu 20.04 without worrying about what Python version Ubuntu has installed. As far as sterilizing system against one version or the other: it seems like a lot of work with no discernible payback? The downside risk is it breaks Ubuntu. Feb 16 '20 at 20:15
  • @WinEunuuchs2Unix : Python 2 is at end of life and it is a goal of the Ubuntu team to eliminate it from 20.04. That is the reason I am attempting to keep one of my 20.04 test servers "clean". There are bunch of scripts in the kernel source tree that will need to be fixed. I only use and fixed one of them. Feb 17 '20 at 15:43

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.