How to Install Python Pip on Ubuntu 20.04

Pip is a package management system that simplifies installation and management of software packages written in Python used to install and manage software packages.

Installing pip for Python 3

$ sudo apt update
$ sudo apt install python3-pip

When the installation is complete, verify the installation by checking the pip version:

$ pip3 --version

You will see the output from that command as below

 pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

Installing pip for Python 2

You have to enable the universe repository:

$ sudo add-apt-repository universe

Stating to install Python 2:

$ sudo apt update 
$ sudo apt install python2

Download the get-pip.py script by using curl tool:

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

Once the repository is enabled, you can install pip for Python 2:

$ sudo python2 get-pip.py

Verify the installation by checking the pip version number:

$ pip2 --version
pip 20.0.2 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

Installing Packages with Pip

To install a package with pip, you use the syntax:

pip3 install <name of package>

If you have a list packages want to install to your program can use, you will write down all of them with their version to requirements.txt file then do:

$ pip3 install -r requirements.txt

Conclusion

This post shown you how to install pip on your Ubuntu machine and how to manage Python packages using pip.

For more information about pip, visit the pip user guide page.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s