Installing Python 2.7 and pip on Ubuntu 24.04 Noble LTS
Installing Python 2.7 and pip on Ubuntu 24.04 Noble LTS
see https://github.com/ctch3ng/Installing-Python-2.7-and-pip-on-Ubuntu-24.04-Noble-LTS
Ubuntu 24.04 does not include Python 2.7 by default, as it has reached its end of life. However, if you need it for legacy applications, you can install it by compiling from source.
-
Update the system packages:
sudo apt update && sudo apt upgrade
-
Install required dependencies:
sudo apt install -y build-essential checkinstall libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev
-
Download Python 2.7.18 source code:
cd /usr/src wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
-
Extract the downloaded file:
tar xzf Python-2.7.18.tgz cd Python-2.7.18
-
Configure and compile Python 2.7:
./configure --enable-optimizations make sudo make install
-
Verify installation:
python -V
Expected output:
Python 2.7.18
- Install
curl
if not installed:sudo apt install curl
- Download the
get-pip.py
script:curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
- Run the script using Python 2.7:
sudo python2.7 get-pip.py
- Verify pip installation:
pip2.7 --version
Python 2 is deprecated and no longer maintained. It is recommended to transition to Python 3 for ongoing support and security updates.
=========== End