What Is PIP And How To Use It?
As you read in the previous lessons, installing Python on your PC includes a limited set of packages and modules
that we can use by default. Those that are not already installed can be easily obtained using
PIP.
Python Package Index (abbreviated as
PIP) is a package management system for
the Python programming environment.
PIP allows the installation, update, and management of packages and their dependencies from a centralized registry
called the
Python Package Index.
With it, you can install Python packages from
PyPi (
Python Package Index) or from other sources.
PyPI is an online repository containing tens of thousands of Python packages developed by the Python community:
https://pypi.org/
List Of Already Installed Packages
To see the list of Python packages already installed on your device, you can use the command "
pip list",
called from the system console ("
cmd.exe"):
Uninstalling A Package
To uninstall a package, in case we no longer need it,
we will use the command "
pip uninstall package_name".
Installing A New Package
To install a new Python package, we will use the command:
pip install package_name
where
package_name represents the official name of the package found in the specific documentation on the
PyPi website.
For example, to perform numerical calculations and matrix manipulations, we need the
NumPy package, which can be easily installed using the command:
pip install numpy
Same Package, Different Versions
PIP allows specifying a specific version of a package when installing or updating:
pip install package_name==version_number
pip install numpy==1.19.2
This allows for exact control over the versions of the packages used in a project, helping to
maintain consistency and reproducibility in the development environment.
Updating A Package
You can update an installed package using the command:
pip install --upgrade package_name
---
In addition to
PyPI,
PIP allows the installation of packages from other sources, such as
Git repositories, local files, or URLs. This provides increased flexibility in managing packages in Python projects.
Throughout the pages of this course, we will use this management system whenever we need certain packages to develop practical applications on various topics.
This concludes the section.