What is PIP in Python?
PIP is a Python package management system which can also be used to install various software written in Python and Python modules and their respective dependencies.
In this module, we will learn about PIP, covering the following topics:
So, without further delay, let’s get started.
Kick-start your career in Python with the perfect Python Course in New York now!
How to Install PIP in Python?
Before we proceed to install pip in Python, we should check once if pip is pre-installed in Python version 3.4 and above.
Checking If PIP Is Installed
This step is important because PIP is pre-installed in Python version 3.4 and above. Then, why go through the trouble of installing it if we already have it in our system? So, before installing PIP, we have to check whether it is already installed in the system or not. In order to check that, just type the following command in the Python Shell:
If we find that we already have PIP in our system, then we can skip the next topic of installing PIP and go straight toward learning how to download a package using PIP.
Go through our Python for Data Science course to learn more concepts in detail.
Installing PIP in Python
In case we do not have PIP installed in our system, follow the below steps to install it:
Step 1: Click here and download the file named get-pip.py
Step 2: Once we have downloaded the get-pip.py file, open our cmd, navigate to the folder where our downloaded get-pip.py file is present, and run the following command:
This command will install and upgrade PIP.
How to Use PIP in Python?
Alright now that we have successfully installed PIP, let us talk about downloading packages using PIP, removing a package using PIP, listing, and searching packages using PIP.
Downloading a Package Using PIP in Python
Downloading a package using PIP is a cakewalk. PIP makes downloading packages and modules really easy and convenient. To download a package, just run the following command in our command line:
pip install scrapy
The above command will download and install the package named ‘scrapy’ which is used for scraping information from websites. We can download any package that we like, by just replacing ‘scrapy’ with the name of the package that we want to install in the above-mentioned command.
Get 50% Hike!
Master Most in Demand Skills Now !
Now that we have installed our package, we can easily use it by simply importing the package in our program using the following syntax:
Removing a Package Using PIP
Removing a package is also as simple as installing it; just type and run the following command in our command line:
PIP uninstall scrapy
The PIP manager will ask us to confirm if we really want to remove the package before removing it. Just type y if we want to remove the package or n if we don’t want to remove it.
Go for the most professional Python Course Online in Toronto for a stellar career now!
Listing and Searching Packages Using PIP
PIP is not only used for installing and uninstalling Python packages. It is a package manager. We can manage all our Python packages using PIP. Moreover, we can search for a package or just list down all the available packages using this package manager.
- To list all packages, type the following command in our command line:
- To search for a particular package, type the following command in our command line
pip search scrapy
This command will search for the package named ‘scrapy’. We can search for any package, by replacing ‘scrapy’ with the name of the package that we want to search for.
With this, we come to an end of this module in Python Tutorial.