In this video, we will take an in-depth look at Python’s package management system, pip. We’ll walk through how to install, uninstall, list, and upgrade packages. We will also dive into how we can output our dependencies and install a list of dependencies.
An in-depth knowledge of pip can be a great addition to your Python tool-belt.
Here is a look at some of the code used in this tutorial:
Install a package
pip install <package_name>
Uninstall a package
pip uninstall <package_name>
Output installed packages to a requirements file.
pip freeze > requirements.txt
Install all packages from a requirements file
pip install -r <name_of_requirements_file>
List installed packages
pip list
List installed packages that need updated
pip list --outdated
Upgrade a package
pip install -U <package_name>
Upgrade all packages (source)
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U