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.
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.
Output: The following set of information should appear on your terminal.
2. Installing PIP on Ubuntu
$ 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.
pip install package-name
pip install pkglts
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.
$ pip list
Removing a package with PIP
If you wish to uninstall any package, the following command can help you with the same.
$ pip uninstall package-name
$ pip uninstall camelcase
Further, you will be asked for your consent whether you really want to uninstall the selected package. Enter ‘y’ to proceed.
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.
$ pip help
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.
$ pip search package-name
$ pip search Flask
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.
$ pip show package-name
$ pip show Flask
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.