Install pip in Python

In Python, we can install Python packages by using the pip command called a package manager in Python.

Install pip On Windows

Note: The below instructions assume that you have already installed Python on your Windows system. pip typically comes bundled with Python installations starting from Python 3.4 onwards.

Open Command Prompt:

  • Got to Run or press Win+R, type cmd, and press Enter. This will open the Command Prompt.

Check if the pip is already installed:

Run the following command to check if pip is already installed:

pip --version

If you see version information, pip is already installed, and you can skip the installation process.

Download get-pip.py:

  • If pip is not installed, you can download and install it manually. To do this, open a web browser and go to the following URL to download the get-pip.py script:
https://bootstrap.pypa.io/get-pip.py

Install pip:

  • In the Command Prompt, navigate to the directory where you downloaded get-pip.py. You can use the cd command to change the working directory of the working drive or another letter drive. For example:
cd C:\Users\YourUsername\Downloads

Once you’re in the directory where get-pip.py is located, run the following command to install pip:

python get-pip.py

This command will execute the script, which will download and install pip for you.

Verify pip installation:

  • To ensure that pip is installed correctly, you can run the following command:
pip --version

The above command displays the version information for pip.

Install pip in Python

Now you have successfully installed pip on your Windows system. You can use pip to install Python packages and manage your Python environment.

Install pip On Linux

 It usually comes pre-installed with Python versions 3.4 and newer. However, if you need to install pip separately or update it, you can follow these steps:

1. Check if pip is installed:

Open your command prompt or terminal and run the following command to check if pip is already installed:

pip --version

If it’s installed, you’ll see the version information. If not need to install following below steps.

For Python 3. x:

If you have Python 3. x installed (which is recommended), you can use the following command to install or upgrade pip:

python -m ensurepip --default-pip

This command ensures that the command pip is installed and is up-to-date.

For Python 2. x (Not recommended, as Python 2 is end-of-life):

If you’re using Python 2. x, you can install pip using the following command:

python -m ensurepip --default-pip

However, it’s important to note that Python 2 is no longer supported and is considered outdated. It’s strongly recommended to use Python 3 and check the Python version for existing projects before Python installation.

3. Verify pip installation:

After running the installation command, you can verify that pip is installed by running:

pip --version

This should display the pip version installed on the system

Once pip is installed, you can use it to easily install Python packages. For example, to install a package named bs4, you can use the following command:

pip install bs4

This will download and install the bs4 package, along with its dependencies, if any. You can replace requests with the name of any other package you want to install.

Recommended Articles

Leave a comment