PIP in Python

Many programming languages offer a package manager that automates the process of installing, upgrading, and removing third-party packages. The de facto package manager for Python is called PIP.

In Python, PIPis an essential and powerful tool that enables the Python user to manage distribution packages in Python. PIPis one of the most widely used package management tools.  Its main function is to install and manage the software packages that are written in Python and contained in Python Package Index (PyPi). It stands for Preferred Installer Program.

Installing Third-Party Packages With PIP

PIP is a command line tool. That means you must run it from a command line or terminal program.

Press the Windows key, type cmd, and press Enter to open the Command Prompt application.

Alternatively, you may use the PowerShell application by pressing the Windows key, typing PowerShell, and pressing Enter.

To install the PIP type, do the following:

python get-pip.py

Once you’ve installed PIP, you can test whether the installation has been successful by typing the following:

pip help

Upgrading pip to the Latest Version

Before we go any further, let’s make sure that you have the latest version of pip installed. To upgrade PIP,  type the following into your terminal and press Enter : 

python3 -m pip install –upgrade pip

If a newer version of pip is available, it will be downloaded and installed. Otherwise, you will see a message indicating that the latest version is already installed.

Listing All Installed Packages 

You can use pip to list all of the packages you have installed. Let’s take a peek at what is currently available. Type the following into your terminal:

python3 -m pip list

Installing a Package

Install the pandas package, which is one of the most popular Python packages. The simplest way to do it is by running the following instructions:

pip install pandas

While pip is installing the pandas package, you will see a bunch of output:

Show Package Details 

you can use pip to view some details about the package:

python3 -m pip show pandas

Uninstalling a Package 

If you can install a package with pip, it only makes sense that you can also uninstall a package. Let’s uninstall the requests package now. 

To uninstall requests, type the following into your terminal:

python3 -m pip uninstall pandas

Pip will ask for your permission before removing anything from your computer. To continue, type y and press Enter. The following message should appear, confirming that the request was removed: 

Successfully uninstalled requests-2.22.0

Conclusion

You learned how to use Python’s package manager pip to install third-party packages. You have seen a number of useful pip commands, such as pip install, pip list, pip show, and pip uninstall.

Not every package available through pip is suitable for your project.

 

Visited 1 times, 1 visit(s) today