![]() |
VOOZH | about |
Python PIP is the package manager used to install, update and manage Python packages and libraries. It allows users to easily download packages from the Python Package Index (PyPI) directly through the command line. PIP is commonly used to add external libraries that are not included with Python by default.
The basic syntax of a PIP command is:
pip <command>
Use the following command in the terminal or command prompt to check whether PIP is installed:
pip --version
This command displays the installed version of PIP.
If PIP is not installed on your system, refer to this article Python pip Installation.
PIP provides the install command to download and install Python packages from PyPI. For example, the following command installs the NumPy package. Below is the syntax:
pip install package_name
For Example:
pip install numpy
You can install a specific version of a package using the == operator with the package name. Below is the syntax:
pip install package_name==version
Example:
pip install numpy==1.26.4
This command installs version 1.26.4 of the NumPy package.
The pip show command is used to display details about an installed package such as version, location and dependencies. Below is the syntax:
pip show package_name
Example:
pip show numpy
The pip list command is used to display all packages installed in the current Python environment. Below is the syntax:
pip list
Example:
The pip uninstall command is used to remove an installed package from the system. Below is the syntax:
pip uninstall package_name
Example:
pip uninstall numpy
Note: This command removes only the selected package. Dependencies installed separately are not removed automatically.
A requirements.txt file is used to install multiple packages at once. Below is the requirements.txt:
Syntax:
pip install -r requirements.txt
Example:
The pip freeze command displays installed packages along with their versions. Below is the syntax:
pip freeze
Example:
The pip list --outdated command shows packages that have newer versions available. Below is the syntax:
pip list --outdated
Example:
The pip install --upgrade command updates a package to the latest version. Below is the syntax:
pip install --upgrade package_name
Example:
pip install --upgrade numpy
We can also upgrade any package to a specific version using the below command.
pip install --upgrade numpy==2.0.0
You can install an older version of a package by specifying the required version. Below is the syntax:
pip install package_name==version
Example:
pip install numpy==1.26.4