0% found this document useful (0 votes)
133 views

Get To Know The Most Useful Pip Commands To Help You Install, Manage, and Use Python Software Packages

This document provides a cheat sheet for the pip command line tool, which is used to install and manage Python packages. It defines key terminology like distributions and packages. It outlines the most common pip commands for installing, searching for, and managing packages from PyPI and other sources. These include commands for installing specific versions, freezing environments, and using custom package indexes and pre-built wheel files.

Uploaded by

lazaru5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views

Get To Know The Most Useful Pip Commands To Help You Install, Manage, and Use Python Software Packages

This document provides a cheat sheet for the pip command line tool, which is used to install and manage Python packages. It defines key terminology like distributions and packages. It outlines the most common pip commands for installing, searching for, and managing packages from PyPI and other sources. These include commands for installing specific versions, freezing environments, and using custom package indexes and pre-built wheel files.

Uploaded by

lazaru5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Opensource.

com: pip Cheat Sheet By Moshe Zadka

Get to know the most useful pip commands to help you install, manage, and use Python
software packages.
Terminology
A “distribution” is something that pip can install.
A “package” is something that can be used in import statements.
Most distributions include a single package of the same name, but there are exceptions. For example, pip install attrs
installs a package importable with import attr
A “wheel” is a special file with the suffix .whl
Installing a wheel just copies files into place. No compiling or processing is required.

Package sources Search


Install package from PyPI Search for packages mentioning “term”
$ pip install requests pip search <some term>
Install package from a local wheel file
$ pip install requests-2.22.0-py2.py3-none-any.whl Show
Install package from a Git repository Show details of package
$ pip install git+https://github.com/psf/requests.git pip show <some package>
It is usually easier to search and view information
Install package from a directory
using the PyPI.org web site
$ pip install /home/user/src/requests

Package versions Download


Install specific version Download a package and all of its dependencies.
$ pip install requests==2.22.0 Except in unusual cases, it is better to run “pip wheel”
Install most recent version in a range and have the packages in a wheel format.
$ pip install requests>=2.22.0,<3 pip download <package>

Install package, avoid a specific version List Installed


$ pip install requests!=2.21.0
Lists all modules currently installed by pip. Usually
Freezing (useful for recording an environment so it can be pip freeze is a better alternative.
duplicated later) pip list
Capture all currently installed versions in a text file
$ pip freeze > requirements.txt
Install packages from a requirements file
$ pip install -r requirements.txt

Custom indexes
Install from an alternative index to PyPI
$ pip install --index-url https://our-pypi-proxy.internal.example.com
Install packages using an *extra index* for local, unpublished externally, packages.
$ pip install --extra-index-url https://local-pacakges.internal.example.com

WHEELs
Produce wheels of the package and all its dependencies,
and put them in the “wheelhouse” directory
pip wheel --wheel-dir ./wheelhouse/ some-package[==version]
Produce wheels of all packages named in requirements file,
and put them in the “wheelhouse” directory
pip wheel --wheel-dir wheelhouse -r requirements.txt

opensource.com Twitter @opensourceway | facebook.com/opensourceway | CC BY-SA 4.0

You might also like