How To Install Pip On Ubuntu 20.04
Pip stands for Pip Installs Packages, a package management system similar that allows you to install and manage software packages written in Python. Pip installs packages listed in the PyPI (Python Package Index).
Pip is not installed on Ubuntu 20.04 by default.
In this post, we will see how to install Pip for Python 3 on Ubuntu 20.04. Apart from the pip installation, we will also see how to manage Python packages with pip.
Prerequisites
You must be logged into a system as the root user or a user with sudo privileges.
Install Pip for Python 3
Python 3 is installed by default in Ubuntu 20.04. Use the command below to verify it.
python3 --version
Output: Python 3.8.2
The above output confirms that your system has Python 3.
We will now install the python3-pip package that will provide pip for Python3.
sudo apt update
sudo apt install -y python3-pip
Once the pip installation is complete, verify the installation by checking its version.
pip3 --version
Output: pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
The above output confirms that the pip for Python 3 is successfully installed.
How to Use Pip
We will go through some basics of how to use pip commands.
Install Packages Using Pip
To install a package using Pip, you can use the below command.
pip3 install PACKAGE_NAME
For example, to install the latest version of the package called IPython, use the below command.
IPython is a powerful interactive Python shell.
pip3 install IPython
To install a specific version of the IPython, you can run the below command.
pip3 install IPython==6.0
List Installed Pip Packages
To list the installed Python packages, use the below command.
pip3 list
Output: . . . httplib2 (0.9.2) idna (2.6) ipython (7.5.0) ipython-genutils (0.2.0) jedi (0.13.3) keyring (10.6.0) . . .
Upgrade Package Using Pip
To upgrade a package to the latest version, use the below command.
pip3 install --upgrade IPython
Remove Package Using Pip
To remove a Python package, you can use the below command.
pip3 uninstall IPython
Search Packages using Pip
Pip’s search functionality lets you find packages name in the terminal. This command will get the packages list from the PyPI (Python Package Index).
pip3 search google
Output: google (2.0.2) - Python bindings to the Google search engine. oauthkit-google (0.1.2) - OAuthKit for Google bits-google (1.8.6) - BITS Google google-gax (0.16.0) - Google API Extensions google-finance (0.1.0) - Google Finance API google-oauth (1.0.1) - OAuth2 for Google APIs google-auth (1.6.3) - Google Authentication Library . . .
Conclusion
That’s All. I hope you have learned how to install Pip on Ubuntu 20.04 and manage Python packages using pip. You can visit Pip’s user guide page to learn more about pip.