Run these commands to ensure your repositories are up to date before installing

Copysudo apt update
sudo apt upgrade
sudo apt install python2.7

Then to install pip for python 2:

Copysudo apt install python-pip
Answer from Spiff on Stack Overflow
Discussions

Python 2.7.18 is installed yet only Python 2.7.17 only shows up with Python2 -V
Why on earth are you using the unsupported legacy Python instead of a recent version of Python 3? The last few versions of Ubuntu include Python 3, python3 myfile.py on command line. More on reddit.com
๐ŸŒ r/learnpython
12
0
February 15, 2022
What is the safest way to work with Python 2 on Ubuntu 24.04?
Containerisation if left up to me More on reddit.com
๐ŸŒ r/learnpython
18
12
August 7, 2024
Trying to remove python 2.7 on ubuntu 18.04.

I suggest NOT messing with removing Python unless you really know what you are doing.

18.04 includes python3 - it is called.... python3 so you can have both 2.7 and 3.0 installed with No hassle..

So you may be going about this the totally wrong way.

Good Luck.

More on reddit.com
๐ŸŒ r/linuxquestions
29
6
June 14, 2020
๐ŸŒ
TecAdmin
tecadmin.net โ€บ install-python-2-7-on-ubuntu-and-linuxmint
How to Install Python 2.7 on Ubuntu, Debian & Linux Mint
April 26, 2025 - Learn to install Python 2.7 on Ubuntu, Debian & Linux Mint. Our guide covers the full process, ensuring a secure setup for legacy applications.
๐ŸŒ
LinuxConfig
linuxconfig.org โ€บ home โ€บ install python 2 on ubuntu 18.04 bionic beaver linux
Install Python 2 on Ubuntu 18.04 Bionic Beaver Linux
May 27, 2020 - Learn how to install Python 2 on Ubuntu 18.04 using a simple command. Verify Python versions and manage packages easily. Read more now!
๐ŸŒ
Medium
medium.com โ€บ @kallagoutham33 โ€บ how-to-install-python-2-on-ubuntu-24-04-12c0819278ba
How to install Python 2 on Ubuntu 24.04 | by Goutham Kalla | Medium
October 6, 2025 - In this guide, youโ€™ll learn exactly how to bring Python 2 back to life on Ubuntu 24.04 โ€” by compiling it from source, setting up pip2 ยท Step 1: Install Build Dependencies These packages provide the libraries Python 2 needs to build ...
๐ŸŒ
LinuxConfig
linuxconfig.org โ€บ home โ€บ how to install python2 on ubuntu 26.04
How to Install Python2 on Ubuntu 26.04
March 22, 2026 - Verify the installation: Confirm Python 2 is working correctly. $ ~/.pyenv/versions/2.7.18/bin/python --version Python 2.7.18
๐ŸŒ
YouTube
youtube.com โ€บ watch
Episode 74: Installing Python 2.7 & 3 8 on Ubuntu 18 04 6
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
Find elsewhere
๐ŸŒ
LinuxShout
linux.how2shout.com โ€บ home โ€บ how to install python 2.7 on ubuntu 20.04 lts
How to install Python 2.7 on Ubuntu 20.04 LTS - LinuxShout
June 18, 2024 - Once done with the above command, it is time to install the Python 2.7 version on Ubuntu Linux, for that, follow this syntax: sudo apt install python2-minimal ยท Check Python2 version ยท To view the current version of Python on your system run: ...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ python 2.7.18 is installed yet only python 2.7.17 only shows up with python2 -v
r/learnpython on Reddit: Python 2.7.18 is installed yet only Python 2.7.17 only shows up with Python2 -V
February 15, 2022 -

Hi everyone,

I'm using a laptop with Ubuntu and I have just installed Python 2.7.18 using this tutorial https://tecadmin.net/install-python-2-7-on-ubuntu-and-linuxmint/ . When I execute Python2 -V, it shows me Python 2.7.17 as the version of Python installed. However, if I execute Python2.7 -V, it shows me Python 2.7.18 as the Python version (see screenshot drive link to see the issue). What does this mean? In my (other) Windows laptop, when I execute Python2 -V, it shows me Python 2.7.18 so why doesn't it happen here in my Ubuntu laptop? Thanks in advance.

Screenshot link: https://drive.google.com/file/d/18xlyZU8eEjBb4U90RwLq8g_oKUxCO_ud/view?usp=sharing

๐ŸŒ
Python
docs.python.org โ€บ 2 โ€บ installing โ€บ index.html
Installing Python Modules โ€” Python 2.7.18 documentation
July 19, 2020 - python2 -m pip install SomePackage # default Python 2 python2.7 -m pip install SomePackage # specifically Python 2.7 python3 -m pip install SomePackage # default Python 3 python3.4 -m pip install SomePackage # specifically Python 3.4
๐ŸŒ
Vultr
docs.vultr.com โ€บ how-to-install-python-2-on-ubuntu-22-04
How to Install Python 2 on Ubuntu 22.04 Complete Guide | Vultr Docs
July 2, 2025 - Python 2.7.18 is the latest version available for Ubuntu 22.04. Install Python 2 from the official Ubuntu repository and confirm the installation.
๐ŸŒ
Aster
aster.cloud โ€บ home โ€บ how to: install python 2.7 in ubuntu
How To: Install Python 2.7 In Ubuntu - aster.cloud
May 3, 2019 - # At a CLI interface $ sudo apt-get update $ sudo apt-get install python 2.7 # Verify using Python Shell $ python 2.7 >>> from datetime import datetime >>> datetime.now() >>> exit()</span>
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ what is the safest way to work with python 2 on ubuntu 24.04?
r/learnpython on Reddit: What is the safest way to work with Python 2 on Ubuntu 24.04?
August 7, 2024 -

Hi all! I just started a new job that is having me analyze/write code in Python 2. The reason it is Python 2 and not Python 3 is because we are supporting older systems that require it, and our code must be backwards compatible with these systems.

With that said, the workstation they've supplied me is running Ubuntu 24.04, and I'm at wits end as to how I can SAFELY run Python 2 code on it. From what I've gathered, recent versions of Ubuntu depend on Python 3 packages so it isn't as simple as adding a legacy apt repo and installing Python 2 - it would break my OS.

So, the question remains: How can I safely work with Python 2 without bricking my OS? Do I need to containerize or use virtualization? Thank you!

๐ŸŒ
Greenwebpage
greenwebpage.com โ€บ home โ€บ blog โ€บ how to install python 2 on ubuntu 24.04: 3 quick methods
How to Install Python 2 on Ubuntu 24.04: 3 Quick Methods
April 3, 2025 - wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz ยท Once the file has been downloaded, here is how you extract and compile it: ... Since Python 2.7 is deprecated, setting up pip for it on Ubuntu 24.04 requires a manual installation process.
๐ŸŒ
LinuxConfig
linuxconfig.org โ€บ home โ€บ install python 2 on ubuntu 22.04 jammy jellyfish linux
Install Python 2 on Ubuntu 22.04 Jammy Jellyfish Linux
January 17, 2022 - Learn how to install Python 2 on Ubuntu 22.04. Follow step-by-step instructions to set it as the default Python interpreter.
๐ŸŒ
NetsLovers
netslovers.com โ€บ home โ€บ tutorials โ€บ how to install python 2.7 and pip on ubuntu 22.04 lts?
How To Install Python 2.7 And PIP On Ubuntu 22.04 LTS?
October 24, 2023 - It seems we have Python 3.10 too, so will do the following steps to make our preferred version Python 2.7 the system default one. # sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1 # sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2
๐ŸŒ
Python
python.org โ€บ downloads โ€บ release โ€บ python-2718
Python Release Python 2.7.18 | Python.org
Warning: Python 2.7.18 reached end-of-life on 2020-01-01. It is no longer supported and does not receive security updates.
Top answer
1 of 5
21

Python 2 is no longer installed by default in fresh installations of Ubuntu 18.04 and later. Don't remove python3 from Ubuntu 18.04 and later or else Ubuntu Software, the terminal and many other apps that are installed by default will stop working. If you removed Python 3 and now Ubuntu Software, terminal and other applications don't work follow the instructions in this answer to reinstall it and get all applications working again.

To install Python 2.7 in Ubuntu 18.04 and later open the terminal and type:

sudo apt install python2.7  

To start the Python 2.7 interpreter run this command:

python2.7

To start the Python 3 interpreter run this command:

python3  

Either way the Python interpreter will show a version message when it is started that shows what version of Python you are running.

2 of 5
7

1) To install Python 2 version on Ubuntu 18.04 open up terminal and enter:

sudo apt install python-minimal

or

sudo apt install python2.7

Check version:

python --version


2) If still python 3+ updated list of Python alternatives to perform a switch between any python version is to run:

update-alternatives --config python

Example:

There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.5   2         auto mode
  1            /usr/bin/python2.7   1         manual mode
  2            /usr/bin/python3.5   2         manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in manual mode

and select an appropriate version using selction integer as shown above.


3) If you see: update-alternatives: error: no alternatives for python. Run:

ls /usr/bin/python*

Example output:

/usr/bin/python  /usr/bin/python2  /usr/bin/python2.7  /usr/bin/python3  /usr/bin/python3.5

Next, update the Python alternatives list for each version you whish to use with priority 1 and 2:

update-alternatives --install /usr/bin/python python /usr/bin/python3.5 1
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2

Then run again update-alternatives --config python and select an appropriate version..