In this tutorial, we’ll provide all the necessary steps for you to install Pip in Python on both Windows and Linux platforms. If you’re using a recent version of Python (Python 3.4 and above), pip
is likely already installed. To check if pip
is installed, open a command prompt or terminal and run:
# Check whether Pip is already installed or not
pip --version
If it’s not installed, the above command will result in an error. In that case, you can set it up for your system using the following steps.
Must Read: Python Pip Usage for Beginners
Install Pip in Python
Before we get into the thick and thin of the topic, let’s quickly understand what exactly Pip is and why should we use it.
What is Pip and why do you use it?
pip
is the package installer for Python. It stands for “Pip Installs Packages” or “Pip Installs Python.” It is a tool used for installing and managing Python packages.
Pip serves us many purposes such as the following:
- Install: It helps you easily install new Python programs or libraries. Want to use a tool for web development? Just tell Pip, and it sets it up for you.
- Update and Remove: Pip lets you update your programs to the latest versions. If you don’t need a program anymore, it helps you remove it.
- Organization: Pip keeps things tidy. When you add a new program, it doesn’t mess up your existing ones. It’s like a neat and organized assistant for your Python projects.
Since Python is most used and loved by users on Linux. So let’s first begin to catch up on the steps to install it on the Linux operating system.
Also Check: Install Python packages with pip and requirements.txt
Here’s a more in-depth guide for setting up pip
on Linux:
Steps to Install Pip in Python on Linux
1. Open Terminal:
- Open your terminal application. You can usually find it in your system’s applications or use a keyboard shortcut like
Ctrl + Alt + T
.
2. Update Package List:
Before installing pip
, it’s a good practice to update the package list. Use the following command based on your package manager:
For Debian/Ubuntu:
sudo apt update
For Red Hat/Fedora:
sudo yum update
3. Install pip
:
Use the package manager to install pip
. Again, the command depends on your Linux distribution:
For Debian/Ubuntu:
sudo apt-get install python3-pip
For Red Hat/Fedora:
sudo yum install python3-pip
This command installs pip for Python 3. If you use legacy Python 2, replace python3-pip with python-pip.
4. Verify Installation:
After the installation, you can verify if pip
is installed by checking its version:
pip3 --version
This should display information about the installed pip
version.
5. Optional: Upgrade pip
(Recommended):
Even if you installed the latest version of pip
, it’s a good idea to upgrade to ensure you have the latest features and bug fixes:
sudo pip3 install --upgrade pip
This command upgrades pip
to the latest version.
6. Test pip
Installation:
To make sure pip
is working correctly, you can try installing a simple package. For example, you can get the numpy
package:
pip3 install numpy
This installs the numpy
package, and you should see an output indicating the successful installation.
Now you have pip
working on your Linux system, so get any Python packages you need for your project. In case, any issue occurs, feel free to ask!
Here’s an in-depth guide for configuring pip
on Windows:
Steps to Install Pip in Python on Windows
1. Download get-pip.py
:
- Open your web browser and go to https://bootstrap.pypa.io/get-pip.py.
- Copy the content of the file to a location on your system (e.g., your Downloads\pip folder) and save it as get-pip.py.
2. Open Command Prompt:
Launch the terminal using the following steps:
- Press
Win + R
and launch the Run dialog. - Type
cmd
and press Enter to start the terminal window.
3. Got to the Downloaded Folder:
- Use the
cd
command to switch to the location where you savedget-pip.py
. For example:cd Downloads\pip
4. Run Installation Script:
The get-pip.py
script has everything you need to install Pip. Run it as given below.
python pip\get-pip.py
Note: If you have Python 3 on your system, you might need to use python3
instead of python
. This command installs Pip for Python.
5. Verify Installation:
After the installation, you can verify if pip
is installed by checking its version:
pip --version
This should display information about the installed pip
version.
6. Optional: Upgrade pip
(Recommended):
Even if you installed the latest version of pip
, it’s a good idea to upgrade to ensure you have the latest features and bug fixes.
Copy the following instruction and run in your terminal.
python -m pip install --upgrade pip
Again, if you have the latest Python 3, you might need to use python3
instead of python
.
7. Test pip
Installation:
To make sure pip
is working correctly, you can try installing a simple package. For example, you can fetch the numpy
package:
pip install numpy
This installs the numpy
package, and you should see an output indicating the successful installation.
Now you have pip
running on your Windows system, so install or update any Python package you want. If you encounter any issues or have further questions, let us know via the comment box.
Summary
Pip makes Python development smoother and more efficient by managing the vast ecosystem of available libraries.
In this guide, we walked through the installation of pip
, a tool crucial for handling Python packages. We covered downloading the installer, using the console or terminal to run the installation script, checking the version, optional upgrading for the latest features, and finally, confirming its functionality by installing a package. With pip
installed, managing Python packages becomes straightforward for your projects.
Now, you have the pip
setup, so start managing Python packages for your project. Feel free to ask for further clarification or assistance!
Happy Coding,
Team TechBeamers