PIP is a Python package management system that can also be used to install various software written in Python and Python modules and their respective dependencies.
So, without further delay, let’s get started.
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.
Installing PIP in Python on Windows
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:
Python get-pip.py
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 100% Hike!
Master Most in Demand Skills Now!
Now that we have installed our package, we can easily use it by simply importing the package into our program using the following syntax:
import scrapy
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 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.
How to List and Search Packages with Pip in Python?
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:
pip list
- 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. Go through these Basic Python Interview Questions and Answers to excel in your career.