Python programming language is divided into different packages and modules. Apart from the core Python installation, we can install third-party modules to help us in our project development. The python package manager, which helps us in installing and uninstalling these packages/modules is called PIP.
What is PIP?
PIP is a python package manager that helps us to install, review and use various packages/modules in Python programming.
In order to work with PIP, 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 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.10+. 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
We need to download the PIP installation file to install it on Windows.
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
After installation, run the below command to check whether PIP has been successfully installed on your system or not.
Output: The output should show you how to use PIP and what are the general options and commands that we can use with PIP.
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 the easy_install utility.
$ sudo easy_install pip
If you want to upgrade the PIP, run the following command.
# python3 -m pip install --user --upgrade pip
The –upgrade option is used to upgrade the PIP to the latest version if the pip is already installed. If you will run it for the first time when pip is not installed, it will install the latest version of pip. So, running this command will ensure that your system has latest PIP version.
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
Pip List Packages
If you wish to have a look at the installed packages in your system, the below command can help you out with it.
Pip list command displays the installed packages along with their versions.
$ pip list
PIP uninstall package
The pip uninstall command with the package name is used to remove a package from the Python installation.
$ 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.
1. pip help
The following command can be used to get information about the commands supported by PIP itself.
$ pip help
2. pip search package
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
3. pip show package info
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
Python pip vs venv
Python pip is used to manage packages at the system level. But, we can manage packages at the project level too using venv. The venv command creates virtual environments that are tied to a specific project. We can activate the virtual environment and then use the pip command to install packages only for that virtual environment. It comes in handy when we are working on multiple projects and don’t want to mix up their package dependencies.
Python PIP utility helps us in managing our Python installation modules and packages. We can search a package, and install and uninstall it using the pip command. We can also list out all the installed modules and packages with their versions.
- Python Modules
- Python Packages
- Python Modules vs Packages
- Python Data Analytics Libraries
- Python Course for Beginners