As a Python package installer, pip is a helpful tool for Python programmers. It helps them easily install and manage external tools and code that others have created. With pip, Python developers can quickly add new features to their programs without writing everything from scratch. It’s like having a big library of pre-made parts that we can use to build our projects faster. Whether we're new to Python or already experienced, pip is a handy friend that saves our time and makes programming more fun.
To install pip on Windows, we can use the Python installer or download and install it manually. Here are two common methods to install pip on a Windows machine:
If we have Python installed on our Windows machine, pip should already be available. Starting from Python 3.4, pip is included by default with Python installation.
To check if pip is installed, open the Command Prompt (or PowerShell) and run the following command:
pip --version
If Python isn't installed on our system, the following step-by-step instructions can show us how to install pip along with Python.
Go to the official Python website.
Click the “Downloads” menu and select the latest stable version of Python for Windows, for example, Python 3.9.x.
Scroll down to the “Files” section, and under “Windows installer (64-bit)” or “Windows installer (32-bit),” click the link to download the installer.
Once the installer is downloaded, locate the file (e.g., python-3.9.x-amd64.exe for the 64-bit version), and double-click it to run the installer.
Check the box “Add Python x.x to PATH” during the installation. This option will add Python to our system’s environment variables, allowing us to use Python and pip from the Command Prompt easily.
After the installation is complete, open the Command Prompt (or PowerShell).
Type the following command and press “Enter:”
python --version
We should see the version of Python installed (e.g., Python 3.9.x).
pip
pip
should be automatically installed along with Python. To verify this, type the following command and press “Enter:”
pip --version
We should see the version of pip
installed (e.g., pip x.x.x).
It’s a good practice to upgrade pip to the latest version. To do this, type the following command and press “Enter:”
python -m pip install --upgrade pip
We can now use pip to install Python packages. For example, to install the popular NumPy library, type the following command and press “Enter:”
pip install numpy
pip
will download and install NumPy and its dependencies.
If we don't have Python installed or if pip is missing, we can download and install it manually using the following steps:
get-pip.py
Go to this Bootstrap link and download the get-pip.py
script.
Open the Command Prompt as an administrator. To do this, right-click the “Start” button and choose “Windows PowerShell (Admin),” or “Command Prompt (Admin).”
Use the cd
command to navigate to the directory where we downloaded get-pip.py
.
Run the following command to install pip
:
python get-pip.py
This will start the installation process, and it will automatically download and install the latest version of pip
.
After the installation is complete, we can verify that pip is installed by running the following command:
pip --version
It should display the version number of pip
if the installation was successful.
We should now have pip installed on our Windows machine, and we can use it to manage Python packages and libraries.
We've successfully installed pip on our Windows machine, and we can now use it to manage Python packages and libraries. Remember that pip allows us to install packages globally, but it’s often recommended to use virtual environments to manage packages for different projects to avoid conflicts.