How to Install the pip Package Manager on Ubuntu

Suraj Joshi Mar 13, 2025 Linux Ubuntu
  1. Prerequisites for Installing pip
  2. Installing pip Using the apt Command
  3. Installing pip Using get-pip.py
  4. Managing Python Packages with pip
  5. Conclusion
  6. FAQ
How to Install the pip Package Manager on Ubuntu

Installing the pip package manager on Ubuntu is an essential step for anyone looking to manage Python packages efficiently. Whether you are a beginner or an experienced developer, having pip at your disposal can make your life significantly easier. Pip allows you to install, upgrade, and manage Python packages with just a few simple commands. In this guide, we will walk you through the process of installing pip on Ubuntu using the apt command-line utility.

In this article, we will cover the installation process step-by-step, ensuring that you have a clear understanding of each method. By the end, you will not only have pip installed but also feel confident in using it to enhance your Python development experience. So, let’s dive in and get started!

Prerequisites for Installing pip

Before we jump into the installation process, it’s important to ensure that your Ubuntu system is up to date and that you have Python installed. Most Ubuntu installations come with Python pre-installed, but it’s always good to check.

To verify if Python is installed, you can run the following command in your terminal:

python3 --version

If Python is installed, you will see the version number. If it’s not installed, you can install it using:

sudo apt update
sudo apt install python3

Once you confirm that Python is installed, you can proceed to install pip.

Installing pip Using the apt Command

The easiest and most straightforward way to install pip on Ubuntu is by using the apt package manager. This method is recommended because it ensures that you get the latest version of pip that is compatible with your version of Python.

To install pip, open your terminal and enter the following command:

sudo apt update
sudo apt install python3-pip

This command does two things: first, it updates your package list to ensure you have the latest information about available packages, and second, it installs the pip package manager.

Once the installation is complete, you can verify that pip has been successfully installed by checking its version:

pip3 --version

You should see an output displaying the version of pip installed on your system. This confirms that pip is ready to use for managing your Python packages.

Output:

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

Using the apt command is not only the simplest way to install pip but also the most reliable, as it ensures compatibility with your current Python installation. This method is particularly useful if you are new to Ubuntu or programming in Python.

Installing pip Using get-pip.py

Another method to install pip is by using the get-pip.py script. This approach is useful if you want to install a specific version of pip or if you encounter issues with the apt installation. Here’s how to do it:

First, you need to download the get-pip.py script. You can do this using the curl command:

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

Once the script is downloaded, you can run it using Python:

python3 get-pip.py

This command will execute the script and install pip. After the installation is complete, you can check the pip version again to ensure everything went smoothly:

pip3 --version

Output:

pip 21.0.1 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)

Using the get-pip.py method allows for more flexibility, especially if you need a specific version of pip. However, it is slightly more complex than the apt method, so it’s best suited for users who are comfortable working with command-line scripts.

Managing Python Packages with pip

Now that you have pip installed, you can start using it to manage your Python packages. Pip makes it easy to install, upgrade, and uninstall packages. Here are some common commands you’ll find useful:

  • To install a package, use:

    pip3 install package_name
    
  • To upgrade a package, use:

    pip3 install --upgrade package_name
    
  • To uninstall a package, use:

    pip3 uninstall package_name
    

For example, if you want to install the popular requests library, you would run:

pip3 install requests

Output:

Collecting requests
  Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
Installing collected packages: requests
Successfully installed requests-2.25.1

Pip simplifies the process of managing libraries and dependencies in your Python projects. By using these commands, you can easily keep your environment organized and up to date.

Conclusion

In this article, we explored how to install the pip package manager on Ubuntu using two different methods: the apt command and the get-pip.py script. Both methods are effective, but the apt command is generally the easiest and most reliable for beginners. With pip installed, you are now equipped to manage your Python packages effortlessly.

Remember, pip is a powerful tool that can significantly enhance your development workflow. So, don’t hesitate to explore its capabilities and make the most out of your Python programming experience!

FAQ

  1. What is pip?
    pip is a package manager for Python that allows you to install and manage Python libraries and dependencies.

  2. Can I install pip without Python?
    No, pip is specifically designed to work with Python, so you need to have Python installed on your system first.

  3. How can I upgrade pip to the latest version?
    You can upgrade pip using the command pip3 install --upgrade pip.

  4. What should I do if pip is not working?
    If pip is not working, try reinstalling it using the apt command or the get-pip.py script.

  5. Is pip compatible with Python 2?
    Yes, pip is compatible with both Python 2 and Python 3. However, it’s recommended to use Python 3 since Python 2 is no longer supported.

Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe
Author: Suraj Joshi
Suraj Joshi avatar Suraj Joshi avatar

Suraj Joshi is a backend software engineer at Matrice.ai.

LinkedIn