in , ,

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 ?

In this lab, we will try to install Python 2.7 and PIP On Ubuntu 22.04 (Jammy Jellyfish) as the new Ubuntu Long-Term Support (LTS) distribution.

You have a great opportunity to get Python homework help on AssignmentCore if you need coding experts to help you with your problems.

Ubuntu 22.04 LTS Jammy Jellyfish

Also, you can check Installing Python On Linux Centos Stream 8, and if you were on windows A Simple Way To Installing And Run Python And PIP On Windows.

We will need to:

  1. Update our Ubuntu Server
  2. Install Python 2.7 and PIP2
  3. Make Python 2.7 The Default Python Version Of Our System.

Installing Python 2.7 On Ubuntu 22.04 LTS

First, we need to make sure our system is up to date, so we need to run the following command to complete the update of our Ubuntu Linux.

# sudo apt update
# sudo apt upgrade

And to install Python 2.7

# sudo apt install python2 python2-dev

How to make Python 2.7 the default Python version?

Simply we can check if we have multiple Python versions on our system. by running the command ls -la /usr/bin/python* and listing the available Python binaries, and the output will be similar to the following

# ls -la /usr/bin/python*
lrwxrwxrwx 1 root root 9 Jul 28 2021 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3592504 Jul 1 10:30 /usr/bin/python2.7
lrwxrwxrwx 1 root root 33 Jul 1 10:30 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root 16 Jul 28 2021 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 10 Mar 25 12:41 /usr/bin/python3 -> python3.10
-rwxr-xr-x 1 root root 5905480 Jun 29 12:14 /usr/bin/python3.10

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.

Define a group name python, and set priority for all installed versions

# sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
# sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2

Switch between Python versions and check your default

use the update-alternatives command to select Python 2 as the default version

# sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).

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

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

Check the default version of Python

# python --version
Python 2.7.18

Of course, you can switch back to Python 3.10 as the default system, by using the update-alternatives command as the previous step.

How to install PIP for python 2.7?

And finally, we can install PIP for Python 2.7 by running…

# curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
# python get-pip.py

And the output will similar to the below

# python get-pip.py
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pip<21.0
Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 5.7 MB/s
Collecting setuptools<45
Downloading setuptools-44.1.1-py2.py3-none-any.whl (583 kB)
|████████████████████████████████| 583 kB 50.9 MB/s
Collecting wheel
Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-20.3.4 setuptools-44.1.1 wheel-0.37.1

What do you think?

14 Points
Upvote Downvote

Leave a Reply

Your email address will not be published. Required fields are marked *

beautiful transformation before and after 021

21 Best Amazing Transformations In True Stories With Before And After Photos

nes roms

1090 Nes ROMs For Nintendo Emulator