Requirements File Format

Requirements files serve as a list of items to be installed by pip, when using pip install. Files that use this format are often called “pip requirements.txt files”, since requirements.txt is usually what these files are named (although, that is not a requirement).


The requirements file format is closely tied to a number of internal details of pip (e.g., pip’s command line options). The basic format is relatively stable and portable but the full syntax, as described here, is only intended for consumption by pip, and other tools should take that into account before using it for their own purposes.


# This is a comment, to show how #-prefixed lines are ignored.
# It is possible to specify requirements as plain names.

# The syntax supported here is the same as that of requirement specifiers.
docopt == 0.6.1
requests [security] >= 2.8.1, == 2.8.* ; python_version < "2.7"
urllib3 @

# It is possible to refer to other requirement files or constraints files.
-r other-requirements.txt
-c constraints.txt

# It is possible to refer to specific local distribution paths.

# It is possible to refer to URLs.


Each line of the requirements file indicates something to be installed, or arguments to pip install. The following forms are supported:

  • [[--option]...]

  • <requirement specifier>

  • <archive url/path>

  • [-e] <local project path>

  • [-e] <vcs project url>

For details on requirement specifiers, see Requirement Specifiers. For examples of all these forms, see Examples.


Requirements files are utf-8 encoding by default and also support PEP 263 style comments to change the encoding (i.e. # -*- coding: <encoding name> -*-).

Line continuations

A line ending in an unescaped \ is treated as a line continuation and the newline following it is effectively ignored.


A line that begins with # is treated as a comment and ignored. Whitespace followed by a # causes the # and the remainder of the line to be treated as a comment.

Comments are stripped after line continuations are processed.

Supported options

Requirements files only supports certain pip install options, which are listed below.

Global options

The following options have an effect on the entire pip install run, and must be specified on their individual lines.


To specify --pre, --no-index and two --find-links locations:

--find-links /my/local/archives

Per-requirement options

Added in version 7.0.

The options which can be applied to individual requirements are:

Referring to other requirements files

If you wish, you can refer to other requirements files, like this:

-r more_requirements.txt

You can also refer to constraints files, like this:

-c some_constraints.txt

Using environment variables

Added in version 10.0.

pip supports the use of environment variables inside the requirements file.

You have to use the POSIX format for variable names including brackets around the uppercase name as shown in this example: ${API_TOKEN}. pip will attempt to find the corresponding environment variable defined on the host system at runtime.


There is no support for other variable expansion syntaxes such as $VARIABLE and %VARIABLE%.

You can now store sensitive data (tokens, keys, etc.) in environment variables and only specify the variable name for your requirements, letting pip lookup the value at runtime. This approach aligns with the commonly used 12-factor configuration pattern.

Influencing the build system


This disables the use of wheels (cached or otherwise). This could mean that builds will be slower, less deterministic, less reliable and may not behave correctly upon installation.

This mechanism is only preserved for backwards compatibility and should be considered deprecated. A future release of pip may drop these options.

The --global-option option is used to pass options to


These options are highly coupled with how pip invokes setuptools using the (legacy) build system interface. It is not compatible with newer pyproject.toml build system interface.

This is will not work with other build-backends or newer setup.cfg-only projects.

If you have a declaration like:

FooProject >= 1.2 --global-option="--no-user-cfg"

The above translates roughly into running FooProject’s script as:

python --no-user-cfg install

Note that the only way of giving more than one option to is through multiple --global-option options.