pip hash

Usage

Unix/macOS

  1. python -m pip hash [options] <file> ...

Windows

  1. py -m pip hash [options] <file> ...

Description

Compute a hash of a local package archive.

These can be used with —hash in a requirements file to do repeatable installs.

Overview

pip hash is a convenient way to get a hash digest for use with Hash-Checking Mode, especially for packages with multiple archives. The error message from pip install --require-hashes ... will give you one hash, but, if there are multiple archives (like source and binary ones), you will need to manually download and compute a hash for the others. Otherwise, a spurious hash mismatch could occur when pip install is passed a different set of options, like --no-binary.

Options

-a``, --algorithm <algorithm>

The hash algorithm to use: one of sha256, sha384, sha512

Example

Compute the hash of a downloaded archive:

Unix/macOS

  1. $ python -m pip download SomePackage
  2. Collecting SomePackage
  3. Downloading SomePackage-2.2.tar.gz
  4. Saved ./pip_downloads/SomePackage-2.2.tar.gz
  5. Successfully downloaded SomePackage
  6. $ python -m pip hash ./pip_downloads/SomePackage-2.2.tar.gz
  7. ./pip_downloads/SomePackage-2.2.tar.gz:
  8. --hash=sha256:93e62e05c7ad3da1a233def6731e8285156701e3419a5fe279017c429ec67ce0

Windows

  1. C:\> py -m pip download SomePackage
  2. Collecting SomePackage
  3. Downloading SomePackage-2.2.tar.gz
  4. Saved ./pip_downloads/SomePackage-2.2.tar.gz
  5. Successfully downloaded SomePackage
  6. C:\> py -m pip hash ./pip_downloads/SomePackage-2.2.tar.gz
  7. ./pip_downloads/SomePackage-2.2.tar.gz:
  8. --hash=sha256:93e62e05c7ad3da1a233def6731e8285156701e3419a5fe279017c429ec67ce0

Important

Did this article help?

We are currently doing research to improve pip’s documentation and would love your feedback. Please email us &body=%0A%20%20%20%200.%20Document:%20reference/pip_hash.%20Page%20URL:%20https:/%20%0A%0A%20%20%20%201.%20What%20problem%20were%20you%20trying%20to%20solve%20when%20you%20came%20to%20this%20page?%20%0A%0A%20%20%20%202.%20What%20content%20was%20useful?%20%0A%0A%20%20%20%203.%20What%20content%20was%20not%20useful?) and let us know:

  1. What problem were you trying to solve when you came to this page?

  2. What content was useful?

  3. What content was not useful?