The pip Utility
Reference:
Each programming language generally has its own way of installing third-party packages, and certain files to keep track of a project's package requirements. For Python, the package manager is called Pip, and is usually installed alongside Python (via Anaconda).
Pip will help us install third-party Python packages, like ones we might find shared on GitHub, or more officially on PyPI, the Python Package Index.
Usage
Listing Packages
Listing packages currently installed:
Installing Packages
We can install packages one at a time (not recommended):
Project-specific Package Management
We can also manage project-specific package dependencies by listing them all in a special file called "requirements.txt" in the project's root directory. This is the recommended approach that allows us to install all the packages at once, and also keeps an official record of their versions. It is possible for "breaking changes" from updated versions of underlying packages to introduce bugs into our apps, so it is helpful to keep track of which versions are being used.
If we have an existing project, we can pip freeze > requirements.txt
to create a new requirements file to reflect the existing environment. But more commonly, we'll create the requirements file first and build the environment around it.
First create a new "requirements.txt" file in your repository's root directory, then revise the file to include the names of the packages your project requires. Write the name of each Python package dependency on a new line. For example, any of the following:
Make sure to save the file. Then finally, use Pip to install package dependencies by specifying the requirements filepath:
Last updated