Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages

Python PIP – Package Manager

Python PIP (1)

In this article, we will be understanding the tool or key element to fetch the modules onto our system i.e. Python package manager (PIP). Python serves us with various modules to acquire the functionalities and enables us to perform manipulation with the data-sets.


Getting started with Python PIP

Python PIP is a python package manager that basically helps the users install, review and use various packages/modules in Python programming.

In order to work with PIP, at first we need to download and set up the PIP on our system.

Make sure that Python is already installed in your system. That’s a prerequisite for installing Python PIP.


Installing PIP

PIP can be installed on different platforms. Let’s see how to install it on Windows, Linux, and Mac OS.

PIP comes bundled with Python installers i.e. versions 2.7.9+ or 3.4+. You will need to explicitly install it if you are on the older version or if you want to update it.

1. Installing PIP on Windows

In order to start using Python PIP in Windows, we will need to download the PIP installation file.

You can copy the installation script from this link: https://bootstrap.pypa.io/get-pip.py

Copy the content from the above URL and save it with the name get-pip.py, after which you need to open the command prompt and cd into the directory where the get-pip.py file is saved and run the file.

$ python get-pip.py

In order to check whether PIP has been successfully installed on your system, run the below command on your CMD.

Syntax:

$ pip

Output: The following set of information should appear on your terminal.

PIP Installation
PIP Installation

2. Installing PIP on Ubuntu

Syntax:

$ sudo apt-get install python-pip

3. Installing PIP on Mac OS

We can use easy_install to install PIP too. Actually, both of them are package managers and PIP has replaced easy_install utility.

$ sudo easy_install pip

Downloading a package with PIP

Python consists of various modules and packages that can be downloaded and accessed using PIP.

Syntax:

pip install package-name

Example:

pip install pkglts

Output:

PIP install Command
PIP install Command

Listing the packages

If you wish to have a look at the installed packages in your system, the below command can help you out with it.

The list command displays the installed packages along with their versions.

Syntax:

$ pip list

Output:

PIP List Packages
PIP List Packages

Removing a package with PIP

If you wish to uninstall any package, the following command can help you with the same.

Syntax:

$ pip uninstall package-name

Example:

$ pip uninstall camelcase 

Further, you will be asked for your consent whether you really want to uninstall the selected package. Enter ‘y’ to proceed.

Output:

PIP Uninstall Package
PIP Uninstall Package

Commands supported by PIP

PIP contains a lot of commands to analyze and work with the Python modules and packages.

The following command can be used to get information about the commands supported by PIP itself.

Syntax:

$ pip help

Output:

PIP help Command
PIP help Command

Searching packages with PIP

We may sometimes not know the exact package name and Python PIP has a solution for that too. We can easily search for a package in the PIP repository using the following command.

Syntax:

$ pip search package-name

Example:

$ pip search Flask

Output:

PIP search Command
PIP search Command

Information about an installed package

If you wish to fetch the information about the installed package/module such as the location of storage and the latest version, then PIP can help us out with it using the below command.

Syntax:

$ pip show package-name

Example:

$ pip show Flask

Output:

PIP show Command
PIP show Command

Conclusion

Thus, in this article, we have understood the usage and working of the Python PIP repository. We hope that you’ll now be able to work with Python packages in a better manner.


References

Leave a Reply

Your email address will not be published. Required fields are marked *