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.

Installing Python 2.7

  1. Update the system packages:

    sudo apt update && sudo apt upgrade
     
  2. 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
     
  3. 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
     
  4. Extract the downloaded file:

    tar xzf Python-2.7.18.tgz
    cd Python-2.7.18
     
  5. Configure and compile Python 2.7:

    ./configure --enable-optimizations
    make
    sudo make install
     
  6. Verify installation:

    python -V
     

    Expected output:

    Python 2.7.18
    
     

Installing pip for Python 2.7

  1. Install curl if not installed:
    sudo apt install curl
     
  2. Download the get-pip.py script:
    curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
     
  3. Run the script using Python 2.7:
    sudo python2.7 get-pip.py
     
  4. Verify pip installation:
    pip2.7 --version
     

Disclaimer

Python 2 is deprecated and no longer maintained. It is recommended to transition to Python 3 for ongoing support and security updates.

References

 

=========== End

 

posted @ 2025-04-19 09:59  lsgxeva  阅读(277)  评论(0)    收藏  举报