Unable to Locate package python2 | Installation of python2 under Linux Ubuntu system

Installation of python2 under Linux Ubuntu system

The installation script of FSL is written in Python2. New versions of Ubuntu (16 and later) do not install Python2 by default. Enter python2 in the terminal. If it prompts that there is no corresponding command, you need to install Python2 first, as follows:

sudo apt install python2

报错1:
Ubuntu20.04 "sudo apt-get install python2“导致"E: Unable to locate package python2
Unable to locate package

Solution 1:
Installation background of python2 under Linux Ubuntu system
: The official has announced to stop the updates and services of Python 2 many years ago, so for versions after ubuntu20, python3 is installed, but we are dealing with the installation of some large scientific When calculating programs, it is often necessary to use some old libraries and programs. Here we take FSL installed with python2 as an example. Regarding the error message when installing python2, I tried many methods but none worked:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python2.7

结果:Unable to Locate package

At the same time, we tried to change a variety of different sources (Alibaba source, Tsinghua source all still have the same error reporting problem).
However, we often ignore the background of the official stop of update services, so the key problem still lies in the selection and download of the source. Enter the above, the correct solution is as follows:
enable the universe source warehouse:

sudo add-apt-repository universe

Update sources and install:

sudo apt update 
sudo apt install python2

Check whether the installation is successful:

python2 --version

At this time, the terminal will return the version number of py2, and the installation is successful!
insert image description here

Guess you like

Origin blog.csdn.net/Alexa_/article/details/132476542