pip is a package management system , we can use it to install and manage software packages in python. pip is included by default for python 2.7.9 and later . For python3, it is called pip3 which is also included by default for Python 3.4 and later .
pip is already installed for python >=2.7.9 or for python3 >=3.4 . First check your python version using python -V ( V is capital V) . If your version doesn’t belong to any of the above versions, then you need to install pip manually from this site .
Before using pip, check its version number first using pip -V . If it is showing some output, that means the installation is successful.
Suppose, we want to install package “Pillow” ( image processing library ) using pip. We need to use the following command for installing it :
pip install Pillow
The versions of “Pillow” is mentioned here . If we want to install only 4.1.1 version, then we should use the following command :
pip install Pillow==4.1.1
We can also specify a minimum version number for a package . If it is not available, pip will install the latest version.
pip install Pillow>=4.1.1
You can search for a specific package or similar packages using search command :
pip search Pillow
It will search for all packages similar to “Pillow” and list it down . Mainly it will check for libraries with name or description containing “Pillow” keyword
Upgrade a installed package :
pip install —upgrade name_of_the_package
Get details of a package using the below command :
pip show name_of_the_package
You can build the list of all the installed packages and version numbers using freeze command . The output can also be redirect to a text file file :
pip freeze > requirements.txt
We can also put all the list of packages in a text file like we have done above for “requirements.txt” and install all of them at once using -r or —requirement flag :
pip install -r requirements.txt
For pip version 1.3 and above, you can check for outdated packages installed and latest version available :
To uninstall a package (for this example, we will uninstall Pillow) , use the bellow command :
pip uninstall Pillow
- Python time.sleep method explanation with Example
- Python 3 Ordered Dictionary (OrderedDict) with example
- Python range explanation with example
- How to delete a key from a python dictionary
- Python program to take user input and check validity of a password
- Find the factorial of a number using recursion