In this article we are going to show how to install pip on Ubuntu 18.04 | 20.04. If you want to learn about pip on Ubuntu 18.04 | 20.04 with examples then this post is ideal for you.
Pip is a package management tool that is used for installing Python packages. By the help of pip package management tool, you can search, download and install packages from Python Package Index and other repositories.
Ubuntu is a Linux Operating System based on Debian and mostly composed of non-profit(free) and open-source software. It is a complete Linux operating system that compatible with desktops, laptops, server and other devices. Ubuntu is Open Source so it is freely available for both community and professional support.
If you are a learner and looking for a Linux distribution for Learning then Ubuntu Linux Operating System is best for you as a beginning.
How to Install Pip on Ubuntu 18.04|20.04
Step 1 : Install PiP for Python 3
Run the below command to install pip package management tool for Python version 3:
sudo apt update
sudo apt install python3-pip
When you rub the above command, it will install pip and all required dependencies.
To verify the installation of pip, run the below command:
pip3 --version
When you run the above command, it will display the output similar like below:
Output:
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
Step 2 : Install PiP for Python 2
By default, pip package management tool doesn’t come with Ubuntu for Python 2, so we will install pip for Python 2 using the get-pip.py
script. Simply run the below command to enable the repository and install Python 2:
sudo add-apt-repository universe
sudo apt update
sudo apt install python-pip
The above command enable the universe repository and installed Python 2. Now you can install pip using get-pip.py script. simply just download the script and run it to install pip for Python 2:
curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py
sudo python2 get-pip.py
The above command will install pip, setuptools and wheel which allows you to install source distributions.
Step 3 : How to use PiP for Python 3
If you are new to pip and don’t know that how to use pip, then run the its help command to display some useful basic pip commands options:
pip3 --help
pip install --help
The above command display some basic helpful commands as similar like below:
Usage:
pip [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible
Step 4 : Example:
Install Package Using Pip
Run the below command to install a package:
pip3 install python-openstackclient
The above command will install the python-openstackclient package for the Python 3.
Upgrade a Package using Pip
pip3 install --upgrade python-openstackclient
Uninstalling Packages using Pip
pip3 uninstall python-openstackclient
When you are complete your Python project and want to return to your normal shell then simply run the deactivate command to do that:
deactivate
That’s all
If you face any error and issue in above steps , please use comment box below to report.
If our tutorials helped you, please consider buying us a coffee. We appreciate your support!
Thank you for your support.