Pip is the abbreviation for the “Python Install Packages” used to install and manage the Python packages on Linux distributions and other operating systems. The command-line package manager downloads the packages from the “Package Python Index (PyPI)”.
Pip is a useful command utility for Python developers as it allows them to manage the Python packages and their dependencies on a computer. Pip provides different commands to manage the Python packages including installation, upgradation, and uninstallation of the Python packages on Linux.
How to Install Pip on a Computer?
Pip command-line utility can be installed on the computer by following the different methods depending on the installed operating system. Follow the below-mentioned methods for the installation of “pip” on a computer.
Method 1: Install pip on Linux Using the Terminal
The installation of the “pip” on Linux, open the terminal and run the below-mentioned commands:
$ sudo apt install python3-pip -y #Debian-based Linux Distributions $ sudo dnf install python3-pip -y #Fedora-based Linux Distributions
Method 2: Install Pip on Windows
If “Windows” is installed on the computer, then open the command prompt (cmd) as shown below:
Download the installation script of the “pip” from bootstrap by executing the command:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Finally, install the “pip” using the command:
Method 3: Install Pip on MacOS
The last installation method of “pip” is for MacOS, first, install the “Python” package using the “brew” package manager:
brew install python3
Then use the brew package manager to install the pip package manager:
sudo easy_install pip
When the Pip package is installed on the computer following the above-mentioned method, verify the installation by displaying its version:
$ pip --version
What are the Commands to Manage the Packages Using the pip?
To manage the Python packages using the “pip” command utility, follow the below-mentioned commands.
Install a Package Using the pip
For the installation of the package using the pip, use the “install” option of the “pip” command. For example, install the Python package of “lxml” using the pip:
$ pip install lxml
Display the Package Information Using the pip
To display the information of the package available in the “PyPI”, run the command:
$ pip show lxml
Upgrade a Package Using the pip
To upgrade the installed Python package to its latest version, use the ”upgrade” option:
$ pip install --upgrade lxml
List Down the Packages Using the pip
To list down all the installed packages and their versions on the computer using the pip command, run the command:
$ pip list
Uninstall a Package Using the pip
Finally, the package can be uninstalled using the “uninstall” option of the pip command. Press the “y” to proceed with the uninstallation process as shown below:
$ pip uninstall lxml
These are different ways to use the pip command utility to manage the Python packages on the computer.
To update/upgrade the packages using the pip, open the terminal and run the command “$ pip install –upgrade [package name]”. This post explained the usage of the pip command for managing the Python packages on the computer with examples.