In this article, I’ll quickly guide you through the installation steps for Python’s package installer pip
. But first things first: π
What Is Pip?
β
pip
is the package installer for Python used to install and manage software packages (also known as libraries or modules) written in Python. pip
makes it easy to install, upgrade, and uninstall packages in your Python environment.
When you install a package with pip
, it automatically downloads and installs any dependencies required by the package, making it very convenient for managing your Python projects. You can use pip
from the command line but it also integrates with popular development environments like Jupyter, PyCharm, and Visual Studio Code.
Is Pip Already Included in Python?
pip
is included with Python distributions from version 3.4 onwards, so if you have a recent version of Python installed, you should already have pip
.
β Recommended: How to Check Your Python Version?
If you don’t have pip
installed, you can easily install it using the steps outlined as follows:
5 Steps to Install Pip Easily
To install pip
in Python, follow these steps:
- Check if
pip
is already installed by running the command “pip -V
” in your command prompt or terminal. If you see a version number,pip
is already installed. If not, proceed to step 2.
- Download the
get-pip.py
script from the official Python website (see below). - Open a command prompt or terminal and navigate to the directory where you downloaded the
get-pip.py
script. - Run the command
python get-pip.py
to installpip
. - Verify that
pip
is installed by running the commandpip -V
.
That’s it! You should now have pip
installed and ready to use in your Python environment.
In case you weren’t able to complete step 2, here’s how to do it quickly:
How to Download get-pip.py from Official Python?
To download the get-pip.py script from the official Python website, follow these steps:
- Open a web browser and go to the following URL: https://bootstrap.pypa.io/get-pip.py
- Right-click on the page and select “Save As” (or similar option) to download the file.
- Choose a directory to save the file to and click “Save”.
- Once the download is complete, navigate to the directory where you saved the file.
Alternatively, you can use the following command in your command prompt or terminal to download the file directly:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
This will download the get-pip.py file to your current working directory.
Are There Other Ways to Install Pip?
Yes, there are a few other ways to install pip
depending on your operating system and Python distribution.
Here are the three most common methods:
- Package managers: Many Linux distributions include
pip
in their package repositories, which means you can use your distribution’s package manager to install it. For example, on Ubuntu, you can use the following command:sudo apt-get install python-pip
. - Python installers: Some Python distributions come with
pip
pre-installed, such as Anaconda and ActivePython. If you are using one of these distributions, you should already havepip
installed. - Python package installer: Another way to install
pip
is by using theensurepip
module, which is included with Python since version 3.4. You can use the following command:python -m ensurepip --default-pip
.
Regardless of the method you choose, it’s always a good idea to verify that pip
is installed and working correctly by running the command pip -V
.
How to Upgrade Pip?
To upgrade pip to the latest version, follow these steps:
Step 1: Open a command prompt or terminal and enter the following command to upgrade pip
:
python -m pip install --upgrade pip
The previous command was for Linux or macOS. For Windows, you may want to use:
py -m pip install --upgrade pip
Step 2: Depending on your system configuration, you may need to run this command with administrator privileges. On Linux or macOS, you can use sudo
to run the command as root, like this:
sudo python -m pip install --upgrade pip
Step 3: pip
will download and install the latest version of itself. Once the upgrade is complete, you can verify that pip
is up to date by running the command:
pip --version
This will display the version number of the newly installed pip.
That’s it! You should now have the latest version of pip
installed on your system.
Note that it’s a good idea to keep pip
up to date to take advantage of bug fixes, security updates, and new features. You can check for updates to individual packages installed with pip using the pip list --outdated
command, and upgrade them with pip install --upgrade <package>
.
β Recommended: Pip Commands — The Ultimate Guide