Pip Command Reference
Pip is the standard package manager for Python. It allows you to install and manage additional libraries and dependencies that are not part of the standard Python distribution. This guide provides a quick reference for common Pip commands.
Essential Pip Commands
Package Installation and Management
These commands are fundamental for adding and managing Python packages in your projects.
# To install packages:
pip install <package>...
# To install a package in user space (without system-wide permissions):
pip install --user <package>
# To upgrade an existing package to the latest version:
pip install --upgrade <package>
# To install a specific version of a package:
pip install SomePackage1==1.1.0 'SomePackage2>=1.0.4'
Searching and Viewing Package Information
Discover and inspect available packages and their details.
# To search for a package on the Python Package Index (PyPI):
pip search <package>
# To show detailed information about an installed package:
pip show <package>
Managing Dependencies with Requirements Files
Efficiently manage project dependencies using requirements files.
# To output all installed packages and their versions into a requirements file:
pip freeze > requirements.txt
# To install all packages listed in a requirements file:
pip install -r requirements.txt
Updating Packages
Keep your project dependencies up-to-date.
# To list all outdated packages:
pip list --outdated
# To upgrade all outdated packages to their latest versions:
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
# An alternative method to upgrade outdated packages to the latest version:
pip list --outdated --format=freeze | cut -d = -f 1 | xargs -n1 pip install -U
Further Resources
For more in-depth information and advanced usage, refer to the official Pip documentation and related resources: