python-2.x

Ubuntu 18.04 "sudo apt-get install python2" results in "E: Unable to locate package python2"


In preparation for supporting a Python 2 legacy application I just installed Ubuntu 18.04.5, which includes Python 3 but not Python 2. Pretty much every Python 2 install tutorial website shows the following command for installing Python 2:

sudo apt-get install python2

Upon which I get:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python2

Some sites list these commands first so I tried these as well:

sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install python2

This gives the same results as above.

I setup Ubuntu 20.04 on a different computer and installed Python 2 about a month ago and I could swear I used the same commands and at that time it worked. I also remember something about Python 2 being decommissioned at the end of January 2021 (which just passed).

Was the Python 2 pip package taken down? Is there some way I can verify this? If so, is there some special curl command that can still download Python 2 or a website I can download it from?


Solution

  • After searching the Ubuntu packages, it seems that for some odd reason for Ubuntu 20.04 the name of the Python 2 package is python2 but for Ubuntu 18.04 there is no package named python2. It seems that for Ubuntu 18.04 by running:

    sudo apt-get install python-pip
    

    This installs both pip for Python 2 and Python 2 itself, so this seems to be the best option