Contents
pip install [options] <requirement specifier> ...
pip install [options] -r <requirements file> ...
pip install [options] [-e] <vcs project url> ...
pip install [options] [-e] <local project path> ...
pip install [options] <archive url/path> ...
Install packages from:
pip also supports installing from “requirements files”, which provide an easy way to specify a whole environment to be installed.
Each line of the requirements file indicates something to be installed, and like arguments to pip install, the following forms are supported:
<requirement specifier>
<archive url/path>
[-e] <local project path>
[-e] <vcs project url>
See the pip install Examples for examples of all these forms.
A line beginning with # is treated as a comment and ignored.
Additionally, the following Package Index Options are supported:
For example, to specify –no-index and 2 –find-links locations:
--no-index
--find-links /my/local/archives
--find-links http://some.archives.com/archives
Lastly, if you wish, you can refer to other requirements files, like this:
-r more_requirements.txt
pip supports installing from “requirement specifiers” as implemented in pkg_resources Requirements
Some Examples:
'FooProject >= 1.2' Fizzy [foo, bar] 'PickyThing<1.6,>1.9,!=1.9.6,<2.0a0,==2.4c1' SomethingWhoseVersionIDontCareAbout
Note
Use single or double quotes around specifiers to avoid > and < being interpreted as shell redirects. e.g. pip install 'FooProject>=1.2'.
Starting with v1.4, pip will only install stable versions as specified by PEP426 by default. If a version cannot be parsed as a compliant PEP426 version then it is assumed to be a pre-release.
If a Requirement specifier includes a pre-release or development version (e.g. >=0.0.dev0) then pip will allow pre-release and development versions for that requirement. This does not include the != flag.
The pip install command also supports a –pre flag that will enable installing pre-releases and development releases.
Starting with v1.4, pip will warn about installing any file that does not come from the primary index. As of version 1.5, pip defaults to ignoring these files unless asked to consider them.
The pip install command supports a –allow-external PROJECT option that will enable installing links that are linked directly from the simple index but to an external host that also have a supported hash fragment. Externally hosted files for all projects may be enabled using the –allow-all-external flag to the pip install command.
The pip install command also supports a –allow-unverified PROJECT option that will enable installing insecurely linked files. These are either directly linked (as above) files without a hash, or files that are linked from either the home page or the download url of a package.
These options can be used in a requirements file. Assuming some fictional ExternalPackage that is hosted external and unverified, then your requirements file would be like so:
--allow-external ExternalPackage
--allow-unverified ExternalPackage
ExternalPackage
pip supports installing from Git, Mercurial, Subversion and Bazaar, and detects the type of VCS using url prefixes: “git+”, “hg+”, “bzr+”, “svn+”.
pip requires a working VCS command on your path: git, hg, svn, or bzr.
VCS projects can be installed in editable mode (using the –editable option) or not.
The url suffix “egg=<project name>” is used by pip in it’s dependency logic to identify the project prior to pip downloading and analyzing the metadata.
pip currently supports cloning over git, git+https and git+ssh:
Here are the supported forms:
[-e] git+git://git.myproject.org/MyProject#egg=MyProject
[-e] git+https://git.myproject.org/MyProject#egg=MyProject
[-e] git+ssh://git.myproject.org/MyProject#egg=MyProject
-e git+git@git.myproject.org:MyProject#egg=MyProject
Passing branch names, a commit hash or a tag name is possible like so:
[-e] git://git.myproject.org/MyProject.git@master#egg=MyProject
[-e] git://git.myproject.org/MyProject.git@v1.0#egg=MyProject
[-e] git://git.myproject.org/MyProject.git@da39a3ee5e6b4b0d3255bfef95601890afd80709#egg=MyProject
The supported schemes are: hg+http, hg+https, hg+static-http and hg+ssh.
Here are the supported forms:
[-e] hg+http://hg.myproject.org/MyProject#egg=MyProject
[-e] hg+https://hg.myproject.org/MyProject#egg=MyProject
[-e] hg+ssh://hg.myproject.org/MyProject#egg=MyProject
You can also specify a revision number, a revision hash, a tag name or a local branch name like so:
[-e] hg+http://hg.myproject.org/MyProject@da39a3ee5e6b#egg=MyProject
[-e] hg+http://hg.myproject.org/MyProject@2019#egg=MyProject
[-e] hg+http://hg.myproject.org/MyProject@v1.0#egg=MyProject
[-e] hg+http://hg.myproject.org/MyProject@special_feature#egg=MyProject
pip supports the URL schemes svn, svn+svn, svn+http, svn+https, svn+ssh.
You can also give specific revisions to an SVN URL, like so:
[-e] svn+svn://svn.myproject.org/svn/MyProject#egg=MyProject
[-e] svn+http://svn.myproject.org/svn/MyProject/trunk@2019#egg=MyProject
which will check out revision 2019. @{20080101} would also check out the revision from 2008-01-01. You can only check out specific revisions using -e svn+....
pip supports Bazaar using the bzr+http, bzr+https, bzr+ssh, bzr+sftp, bzr+ftp and bzr+lp schemes.
Here are the supported forms:
[-e] bzr+http://bzr.myproject.org/MyProject/trunk#egg=MyProject
[-e] bzr+sftp://user@myproject.org/MyProject/trunk#egg=MyProject
[-e] bzr+ssh://user@myproject.org/MyProject/trunk#egg=MyProject
[-e] bzr+ftp://user@myproject.org/MyProject/trunk#egg=MyProject
[-e] bzr+lp:MyProject#egg=MyProject
Tags or revisions can be installed like so:
[-e] bzr+https://bzr.myproject.org/MyProject/trunk@2019#egg=MyProject
[-e] bzr+http://bzr.myproject.org/MyProject/trunk@v1.0#egg=MyProject
pip searches for packages on PyPI using the http simple interface, which is documented here and there
pip offers a number of Package Index Options for modifying how packages are found.
See the pip install Examples.
Starting with v1.3, pip provides SSL certificate verification over https, for the purpose of providing secure, certified downloads from PyPI.
PyPI provides md5 hashes in the hash fragment of package download urls.
pip supports checking this, as well as any of the guaranteed hashlib algorithms (sha1, sha224, sha384, sha256, sha512, md5).
The hash fragment is case sensitive (i.e. sha1 not SHA1).
This check is only intended to provide basic download corruption protection. It is not intended to provide security against tampering. For that, see SSL Certificate Verification
pip offers a –download-cache option for installs to prevent redundant downloads of archives from PyPI.
The point of this cache is not to circumvent the index crawling process, but to just prevent redundant downloads.
Items are stored in this cache based on the url the archive was found at, not simply the archive name.
If you want a fast/local install solution that circumvents crawling PyPI, see the Fast & Local Installs.
Like all options, –download-cache, can also be set as an environment variable, or placed into the pip config file. See the Configuration section.
“Editable” installs are fundamentally “setuptools develop mode” installs.
You can install local projects or VCS projects in “editable” mode:
$ pip install -e path/to/SomeProject
$ pip install -e git+http://repo/my_project.git#egg=SomeProject
For local projects, the “SomeProject.egg-info” directory is created relative to the project path. This is one advantage over just using setup.py develop, which creates the “egg-info” directly relative the current working directory.
Setuptools offers the setup_requires setup() keyword for specifying dependencies that need to be present in order for the setup.py script to run. Internally, Setuptools uses easy_install to fulfill these dependencies.
pip has no way to control how these dependencies are located. None of the Package Index Options have an effect.
The solution is to configure a “system” or “personal” Distutils configuration file to manage the fulfillment.
For example, to have the dependency located at an alternate index, add this:
[easy_install]
index_url = https://my.index-mirror.com
To have the dependency located from a local directory and not crawl PyPI, add this:
[easy_install]
allow_hosts = ''
find_links = file:///path/to/local/archives
Install a project in editable mode (i.e. setuptools “develop mode”) from a local project path or a VCS url.
Install from the given requirements file. This option can be used multiple times.
Directory to unpack packages into and build in. The default in a virtualenv is “<venv path>/build”. The default for global installs is “<OS temp dir>/pip_build_<username>”.
Install packages into <dir>.
Download packages into <dir> instead of installing them, regardless of what’s already installed.
Cache downloaded packages in <dir>.
Directory to check out editable projects into. The default in a virtualenv is “<venv path>/src”. The default for global installs is “<current dir>/src”.
Upgrade all packages to the newest available version. This process is recursive regardless of whether a dependency is already satisfied.
When upgrading, reinstall all packages even if they are already up-to-date.
Ignore the installed packages (reinstalling instead).
Don’t install package dependencies.
DEPRECATED. Download and unpack all packages, but don’t actually install them.
DEPRECATED. Don’t download any packages, just install the ones already downloaded (completes an install run with –no-install).
Extra arguments to be supplied to the setup.py install command (use like –install-option=”–install-scripts=<sys.prefix>/bin”). Use multiple –install-option options to pass multiple options to setup.py install. If you are using an option with a directory path, be sure to use absolute path.
Extra global options to be supplied to the setup.py call before the install command.
Install using the user scheme.
Install packages as eggs, not ‘flat’, like pip normally does. This option is not about installing from eggs. (WARNING: Because this option overrides pip’s normal install logic, requirements files may not behave as expected.)
Install everything relative to this alternate root directory.
Compile py files to pyc
Do not compile py files to pyc
Do not Find and prefer wheel archives when searching indexes and find-links locations.
Include pre-release and development versions. By default, pip only finds stable versions.
Don’t clean up build directories.
Base URL of Python Package Index (default https://pypi.python.org/simple/).
Extra URLs of package indexes to use in addition to –index-url.
Ignore package index (only looking at –find-links URLs instead).
If a url or path to an html file, then parse for links to archives. If a local path or file:// url that’s a directory, then look for archives in the directory listing.
Allow the installation of externally hosted files
Allow the installation of all externally hosted files
Allow the installation of insecure and unverifiable files
Enable the processing of dependency links.
$ pip install SomePackage # latest version $ pip install SomePackage==1.0.4 # specific version $ pip install 'SomePackage>=1.0.4' # minimum version
$ pip install -r requirements.txt
$ pip install --upgrade SomePackage
$ pip install -e . # project in current directory $ pip install -e path/to/project # project in another directory
$ pip install -e git+https://git.repo/some_pkg.git#egg=SomePackage # from git $ pip install -e hg+https://hg.repo/some_pkg.git#egg=SomePackage # from mercurial $ pip install -e svn+svn://svn.repo/some_pkg/trunk/#egg=SomePackage # from svn $ pip install -e git+https://git.repo/some_pkg.git@feature#egg=SomePackage # from 'feature' branch $ pip install -e git+https://git.repo/some_repo.git@egg=subdir&subdirectory=subdir_path # install a python package from a repo subdirectory
$ pip install SomePackage[PDF] $ pip install SomePackage[PDF]==3.0 $ pip install -e .[PDF]==3.0 # editable project in current directory
$ pip install ./downloads/SomePackage-1.0.4.tar.gz $ pip install http://my.package.repo/SomePackage-1.0.4.zip
Install from a different index, and not PyPI
$ pip install --index-url http://my.package.repo/simple/ SomePackageSearch an additional index during install, in addition to PyPI
$ pip install --extra-index-url http://my.package.repo/simple SomePackageInstall from a local flat directory containing archives (and don’t scan indexes):
$ pip install --no-index --find-links=file:///local/dir/ SomePackage $ pip install --no-index --find-links=/local/dir/ SomePackage $ pip install --no-index --find-links=relative/dir/ SomePackage
$ pip install --pre SomePackage