How to Install PIP on Ubuntu 22.04 – LinuxWays
pip is a Python standard package manager on Ubuntu that manages Python packages and code libraries included in the project. pip is considered the standard tool when it comes to installing Python packages and their dependencies on Ubuntu. pip is used to install, search, and manage Python packages installed from repositories like Python package Index (Pypl). pip streamlines Python development by making the management of packages efficient.
Outline:
How to Install PIP on Ubuntu 22.04
The pip can be installed using:
Method 1: Install pip on Ubuntu 22.04 Using apt Package Manager
Ubuntu’s official repository contains the pip package that can be installed using the apt package manager. Installing pip using apt is a quick and convenient method for you to install it on Ubuntu. Check the mentioned steps below to install pip on Ubuntu 22.04 using apt.
Step 1: Update Ubuntu
First, It is advised to update the system packages pip on Ubuntu by running the given command:
Step 2: Install pip on Ubuntu Using apt Package Manager
Once the system repositories are updated, install pip on Ubuntu by running the mentioned command:
sudo apt install python3-pip -y
Step 3: Verify the PIP Installation on Ubuntu
Once the pip is installed on Ubuntu, run the given command to verify the pip installation:
Method 2: Install pip on Ubuntu 22.04 from Python
Alternatively, you can download the Python script using wget and then install pip through it on Ubuntu.
Check the instructional steps given below to install pip on Ubuntu from the Python script.
Step 1: Download pip Python Script
Use the below-given wget command to download the Python script on Ubuntu 22.04:
wget https://bootstrap.pypa.io/get-pip.py
Step 2: Run the PIP Python Script
Once the Python script is downloaded, execute the below command to run the script to install pip on Ubuntu 22.04:
You can see a warning that states “The script pip, pip3 and pip3.11 are installed in ‘home/pi/.local/bin’ location which is not on PATH”:
Let’s fix this warning by moving to the next section.
Step 3: Fix the Warning Error
Execute the below command to fix the warning we discussed in Step 2. This command will move the pip directory to the system’s /usr/bin directory, where Terminal will pick and use pip:
sudo cp /home/username/.local/bin/pip /usr/bin
Step 4: Check pip Version
Once the pip is installed, verify it by running the given command:
How to Upgrade PIP3 to the Latest Version on Ubuntu 22.04
If you have already installed pip on your Ubuntu 22.04 and want to update to the most recent version. Then, execute the below command to update pip to the latest version:
sudo pip3 install –upgrade pip
If you see any warning, such as use a virtual environment instead as shown in the above screenshot then use the –break-system-packages flag when upgrading pip to get rid of the warning, as shown below:
pip3 install –upgrade pip –break-system-packages
How to Manage Python pip Packages on Ubuntu 22.04
You can manage Python’s pip packages on Ubuntu by learning about the pip commands. Check the below sections to learn the management of Python’s pip packages on Ubuntu.
Option 1: Install Python pip Packages on Ubuntu
You can install any desired pip package on Ubuntu 22.04 by providing the package name to the pip3 and install command, as shown below:
sudo pip3 install [package_name]
Note: Remember to replace the package_name with the package you want to install.
Option 2: Display PIP Packages on Ubuntu
To get the complete details about the installed pip3 package, simply, combine the pip3 command with the show command and specify the package name you want to display in the Terminal:
sudo pip3 show [package-name]
Make sure to replace the package_name with your desired package.
Option 3: Uninstall Python pip Packages on Ubuntu
You can remove the pip package from Ubuntu 22.04 using the below-mentioned command:
sudo pip3 uninstall [package_name]
Option 4: List Down Installed Python pip Packages on Ubuntu
Execute the below command to get the list of installed pip packages on Ubuntu 22.04:
Option 5: Get the pip Help Manual
To get all the instructions and help to use the pip command, execute the below command:
How to Remove pip from Ubuntu 22.04
You can uninstall pip from Ubuntu by simply running the mentioned command in Terminal:
sudo apt remove python3-pip -y
Conclusion
pip is a Python package manager used to install, update, and remove packages on Ubuntu. pip can be installed on Ubuntu using two methods including the apt package manager and the Python script. The method to install pip through apt is simple. However, it doesn’t ensure installing the latest pip version on the system. However, if you go with the Python script method, you will be able to install the latest pip package on Ubuntu. Apart from that, you will also find methods in this guide to upgrade the existing pip packages on Ubuntu, as well as remove pip from the system. Alongside that, you will also learn how to install, remove, update, search, display, and list already installed pip packages on Ubuntu by following this guide.