Running pip¶
pip is a command line program. When you install pip, a pip
command is added
to your system, which can be run from the command prompt as follows:
Unix/macOS
python -m pip <pip arguments>
python -m pip
executes pip using the Python interpreter you
specified as python. So /usr/bin/python3.7 -m pip
means
you are executing pip for your interpreter located at /usr/bin/python3.7
.
Windows
py -m pip <pip arguments>
py -m pip
executes pip using the latest Python interpreter you
have installed. For more details, read the Python Windows launcher docs.
Installing Packages¶
pip supports installing from PyPI, version control, local projects, and
directly from distribution files.
The most common scenario is to install from PyPI using Requirement Specifiers
Unix/macOS
python -m pip install SomePackage # latest version python -m pip install SomePackage==1.0.4 # specific version python -m pip install 'SomePackage>=1.0.4' # minimum version
Windows
py -m pip install SomePackage # latest version py -m pip install SomePackage==1.0.4 # specific version py -m pip install 'SomePackage>=1.0.4' # minimum version
For more information and examples, see the pip install reference.
Basic Authentication Credentials
This is now covered in Authentication.
netrc Support
This is now covered in Authentication.
Keyring Support
This is now covered in Authentication.
Using a Proxy Server¶
When installing packages from PyPI, pip requires internet access, which
in many corporate environments requires an outbound HTTP proxy server.
pip can be configured to connect through a proxy server in various ways:
-
using the
--proxy
command-line option to specify a proxy in the form
scheme://[user:passwd@]proxy.server:port
-
using
proxy
in a Configuration Files -
by setting the standard environment-variables
http_proxy
,https_proxy
andno_proxy
. -
using the environment variable
PIP_USER_AGENT_USER_DATA
to include
a JSON-encoded string in the user-agent variable used in pip’s requests.
Requirements Files¶
“Requirements files” are files containing a list of items to be
installed using pip install like so:
Unix/macOS
python -m pip install -r requirements.txt
Windows
py -m pip install -r requirements.txt
Details on the format of the files are here: Requirements File Format.
Logically, a Requirements file is just a list of pip install arguments
placed in a file. Note that you should not rely on the items in the file being
installed by pip in any particular order.
Requirements files can also be served via a URL, e.g.
http://example.com/requirements.txt besides as local files, so that they can
be stored and served in a centralized place.
In practice, there are 4 common uses of Requirements files:
-
Requirements files are used to hold the result from pip freeze for the
purpose of achieving Repeatable Installs. In
this case, your requirement file contains a pinned version of everything that
was installed whenpip freeze
was run.Unix/macOS
python -m pip freeze > requirements.txt python -m pip install -r requirements.txt
Windows
py -m pip freeze > requirements.txt py -m pip install -r requirements.txt
-
Requirements files are used to force pip to properly resolve dependencies.
pip 20.2 and earlier doesn’t have true dependency resolution, but instead simply uses the first
specification it finds for a project. E.g. ifpkg1
requires
pkg3>=1.0
andpkg2
requirespkg3>=1.0,<=2.0
, and ifpkg1
is
resolved first, pip will only usepkg3>=1.0
, and could easily end up
installing a version ofpkg3
that conflicts with the needs ofpkg2
.
To solve this problem, you can placepkg3>=1.0,<=2.0
(i.e. the correct
specification) into your requirements file directly along with the other top
level requirements. Like so:pkg1 pkg2 pkg3>=1.0,<=2.0
-
Requirements files are used to force pip to install an alternate version of a
sub-dependency. For example, supposeProjectA
in your requirements file
requiresProjectB
, but the latest version (v1.3) has a bug, you can force
pip to accept earlier versions like so: -
Requirements files are used to override a dependency with a local patch that
lives in version control. For example, suppose a dependency
SomeDependency
from PyPI has a bug, and you can’t wait for an upstream
fix.
You could clone/copy the src, make the fix, and place it in VCS with the tag
sometag
. You’d reference it in your requirements file with a line like
so:git+https://myvcs.com/some_dependency@sometag#egg=SomeDependency
If
SomeDependency
was previously a top-level requirement in your
requirements file, then replace that line with the new line. If
SomeDependency
is a sub-dependency, then add the new line.
It’s important to be clear that pip determines package dependencies using
install_requires metadata,
not by discovering requirements.txt
files embedded in projects.
See also:
-
Requirements File Format
-
pip freeze
-
“setup.py vs requirements.txt” (an article by Donald Stufft)
Constraints Files¶
Constraints files are requirements files that only control which version of a
requirement is installed, not whether it is installed or not. Their syntax and
contents is a subset of Requirements Files, with several kinds of syntax
not allowed: constraints must have a name, they cannot be editable, and they
cannot specify extras. In terms of semantics, there is one key difference:
Including a package in a constraints file does not trigger installation of the
package.
Use a constraints file like so:
Unix/macOS
python -m pip install -c constraints.txt
Windows
py -m pip install -c constraints.txt
Constraints files are used for exactly the same reason as requirements files
when you don’t know exactly what things you want to install. For instance, say
that the “helloworld” package doesn’t work in your environment, so you have a
local patched version. Some things you install depend on “helloworld”, and some
don’t.
One way to ensure that the patched version is used consistently is to
manually audit the dependencies of everything you install, and if “helloworld”
is present, write a requirements file to use when installing that thing.
Constraints files offer a better way: write a single constraints file for your
organisation and use that everywhere. If the thing being installed requires
“helloworld” to be installed, your fixed version specified in your constraints
file will be used.
Constraints file support was added in pip 7.1. In Changes to the pip dependency resolver in 20.3 (2020) we did a fairly comprehensive overhaul, removing several
undocumented and unsupported quirks from the previous implementation,
and stripped constraints files down to being purely a way to specify
global (version) limits for packages.
Same as requirements files, constraints files can also be served via a URL,
e.g. http://example.com/constraints.txt, so that your organization can store and
serve them in a centralized place.
Dependency Groups¶
“Dependency Groups” are lists of items to be installed stored in a
pyproject.toml
file.
A dependency group is logically just a list of requirements, similar to the
contents of Requirements Files. Unlike requirements files, dependency
groups cannot contain non-package arguments for pip install.
Groups can be declared like so:
# pyproject.toml [dependency-groups] groupA = [ "pkg1", "pkg2", ]
and installed with pip install like so:
Unix/macOS
python -m pip install --group groupA
Windows
py -m pip install --group groupA
Full details on the contents of [dependency-groups]
and more examples are
available in the specification documentation.
Note
Dependency Groups are defined by a standard, and therefore do not support
pip
-specific syntax for requirements, only standard dependency
specifiers.
pip
does not search projects or directories to discover pyproject.toml
files. The --group
option is used to pass the path to the file,
and if the path is omitted, as in the example above, it defaults to
pyproject.toml
in the current directory. Using explicit paths,
pip install can use a file from another directory. For example:
Unix/macOS
python -m pip install --group './project/subproject/pyproject.toml:groupA'
Windows
py -m pip install --group './project/subproject/pyproject.toml:groupA'
This also makes it possible to install groups from multiple different projects
at once. For example, with a directory structure like so:
+ project/ + sub1/ - pyproject.toml + sub2/ - pyproject.toml
it is possible to install, from the project/
directory, groups from the
subprojects thusly:
Unix/macOS
python -m pip install --group './sub1/pyproject.toml:groupA' --group './sub2/pyproject.toml:groupB'
Windows
py -m pip install --group './sub1/pyproject.toml:groupA' --group './sub2/pyproject.toml:groupB'
Installing from Wheels¶
“Wheel” is a built, archive format that can greatly speed installation compared
to building and installing from source archives. For more information, see the
specification.
pip prefers Wheels where they are available. To disable this, use the
—no-binary flag for pip install.
If no satisfactory wheels are found, pip will default to finding source
archives.
To install directly from a wheel archive:
Unix/macOS
python -m pip install SomePackage-1.0-py2.py3-none-any.whl
Windows
py -m pip install SomePackage-1.0-py2.py3-none-any.whl
To include optional dependencies provided in the provides_extras
metadata in the wheel, you must add quotes around the install target
name:
Unix/macOS
python -m pip install './somepackage-1.0-py2.py3-none-any.whl[my-extras]'
Windows
py -m pip install './somepackage-1.0-py2.py3-none-any.whl[my-extras]'
Note
In the future, the path[extras]
syntax may become deprecated. It is
recommended to use standard
syntax wherever possible.
For the cases where wheels are not available, pip offers pip wheel as a
convenience, to build wheels for all your requirements and dependencies.
pip wheel requires the wheel package to be installed, which provides the
“bdist_wheel” setuptools extension that it uses.
To build wheels for your requirements and all their dependencies to a local
directory:
Unix/macOS
python -m pip install wheel python -m pip wheel --wheel-dir=/local/wheels -r requirements.txt
Windows
py -m pip install wheel py -m pip wheel --wheel-dir=/local/wheels -r requirements.txt
And then to install those requirements just using your local directory of
wheels (and not from PyPI):
Unix/macOS
python -m pip install --no-index --find-links=/local/wheels -r requirements.txt
Windows
py -m pip install --no-index --find-links=/local/wheels -r requirements.txt
Uninstalling Packages¶
pip is able to uninstall most packages like so:
Unix/macOS
python -m pip uninstall SomePackage
Windows
py -m pip uninstall SomePackage
pip also performs an automatic uninstall of an old version of a package
before upgrading to a newer version.
For more information and examples, see the pip uninstall reference.
Listing Packages¶
To list installed packages:
Unix/macOS
$ python -m pip list docutils (0.9.1) Jinja2 (2.6) Pygments (1.5) Sphinx (1.1.2)
Windows
C:\> py -m pip list docutils (0.9.1) Jinja2 (2.6) Pygments (1.5) Sphinx (1.1.2)
To list outdated packages, and show the latest version available:
Unix/macOS
$ python -m pip list --outdated docutils (Current: 0.9.1 Latest: 0.10) Sphinx (Current: 1.1.2 Latest: 1.1.3)
Windows
C:\> py -m pip list --outdated docutils (Current: 0.9.1 Latest: 0.10) Sphinx (Current: 1.1.2 Latest: 1.1.3)
To show details about an installed package:
Unix/macOS
$ python -m pip show sphinx --- Name: Sphinx Version: 1.1.3 Location: /my/env/lib/pythonx.x/site-packages Requires: Pygments, Jinja2, docutils
Windows
C:\> py -m pip show sphinx --- Name: Sphinx Version: 1.1.3 Location: /my/env/lib/pythonx.x/site-packages Requires: Pygments, Jinja2, docutils
For more information and examples, see the pip list and pip show
reference pages.
Searching for Packages¶
pip can search PyPI for packages using the pip search
command:
Unix/macOS
python -m pip search "query"
Windows
The query will be used to search the names and summaries of all
packages.
For more information and examples, see the pip search reference.
Configuration
This is now covered in Configuration.
Config file
This is now covered in Configuration.
Environment Variables
This is now covered in Configuration.
Config Precedence
This is now covered in Configuration.
Command Completion¶
pip comes with support for command line completion in bash, zsh and fish.
To setup for bash:
python -m pip completion --bash >> ~/.profile
To setup for zsh:
python -m pip completion --zsh >> ~/.zprofile
To setup for fish:
python -m pip completion --fish > ~/.config/fish/completions/pip.fish
To setup for powershell:
python -m pip completion --powershell | Out-File -Encoding default -Append $PROFILE
Alternatively, you can use the result of the completion
command directly
with the eval function of your shell, e.g. by adding the following to your
startup file:
eval "`pip completion --bash`"
Installing from local packages¶
In some cases, you may want to install from local packages only, with no traffic
to PyPI.
First, download the archives that fulfill your requirements:
Unix/macOS
python -m pip download --destination-directory DIR -r requirements.txt
Windows
py -m pip download --destination-directory DIR -r requirements.txt
Note that pip download
will look in your wheel cache first, before
trying to download from PyPI. If you’ve never installed your requirements
before, you won’t have a wheel cache for those items. In that case, if some of
your requirements don’t come as wheels from PyPI, and you want wheels, then run
this instead:
Unix/macOS
python -m pip wheel --wheel-dir DIR -r requirements.txt
Windows
py -m pip wheel --wheel-dir DIR -r requirements.txt
Then, to install from local only, you’ll be using —find-links and —no-index like so:
Unix/macOS
python -m pip install --no-index --find-links=DIR -r requirements.txt
Windows
py -m pip install --no-index --find-links=DIR -r requirements.txt
“Only if needed” Recursive Upgrade¶
pip install --upgrade
now has a --upgrade-strategy
option which
controls how pip handles upgrading of dependencies. There are 2 upgrade
strategies supported:
-
eager
: upgrades all dependencies regardless of whether they still satisfy
the new parent requirements -
only-if-needed
: upgrades a dependency only if it does not satisfy the new
parent requirements
The default strategy is only-if-needed
. This was changed in pip 10.0 due to
the breaking nature of eager
when upgrading conflicting dependencies.
It is important to note that --upgrade
affects direct requirements (e.g.
those specified on the command-line or via a requirements file) while
--upgrade-strategy
affects indirect requirements (dependencies of direct
requirements).
As an example, say SomePackage
has a dependency, SomeDependency
, and
both of them are already installed but are not the latest available versions:
-
pip install SomePackage
: will not upgrade the existingSomePackage
or
SomeDependency
. -
pip install --upgrade SomePackage
: will upgradeSomePackage
, but not
SomeDependency
(unless a minimum requirement is not met). -
pip install --upgrade SomePackage --upgrade-strategy=eager
: upgrades both
SomePackage
andSomeDependency
.
As an historic note, an earlier “fix” for getting the only-if-needed
behaviour was:
Unix/macOS
python -m pip install --upgrade --no-deps SomePackage python -m pip install SomePackage
Windows
py -m pip install --upgrade --no-deps SomePackage py -m pip install SomePackage
A proposal for an upgrade-all
command is being considered as a safer
alternative to the behaviour of eager upgrading.
User Installs¶
With Python 2.6 came the “user scheme” for installation,
which means that all Python distributions support an alternative install
location that is specific to a user. The default location for each OS is
explained in the python documentation for the site.USER_BASE variable.
This mode of installation can be turned on by specifying the —user option to pip install
.
Moreover, the “user scheme” can be customized by setting the
PYTHONUSERBASE
environment variable, which updates the value of
site.USER_BASE
.
To install “SomePackage” into an environment with site.USER_BASE
customized to
‘/myappenv’, do the following:
Unix/macOS
export PYTHONUSERBASE=/myappenv python -m pip install --user SomePackage
Windows
set PYTHONUSERBASE=c:/myappenv py -m pip install --user SomePackage
pip install --user
follows four rules:
-
When globally installed packages are on the python path, and they conflict
with the installation requirements, they are ignored, and not
uninstalled. -
When globally installed packages are on the python path, and they satisfy
the installation requirements, pip does nothing, and reports that
requirement is satisfied (similar to how global packages can satisfy
requirements when installing packages in a--system-site-packages
virtualenv). -
pip will not perform a
--user
install in a--no-site-packages
virtualenv (i.e. the default kind of virtualenv), due to the user site not
being on the python path. The installation would be pointless. -
In a
--system-site-packages
virtualenv, pip will not install a package
that conflicts with a package in the virtualenv site-packages. The —user
installation would lack sys.path precedence and be pointless.
To make the rules clearer, here are some examples:
From within a --no-site-packages
virtualenv (i.e. the default kind):
Unix/macOS
$ python -m pip install --user SomePackage Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
Windows
C:\> py -m pip install --user SomePackage Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
From within a --system-site-packages
virtualenv where SomePackage==0.3
is already installed in the virtualenv:
Unix/macOS
$ python -m pip install --user SomePackage==0.4 Will not install to the user site because it will lack sys.path precedence
Windows
C:\> py -m pip install --user SomePackage==0.4 Will not install to the user site because it will lack sys.path precedence
From within a real python, where SomePackage
is not installed globally:
Unix/macOS
$ python -m pip install --user SomePackage [...] Successfully installed SomePackage
Windows
C:\> py -m pip install --user SomePackage [...] Successfully installed SomePackage
From within a real python, where SomePackage
is installed globally, but
is not the latest version:
Unix/macOS
$ python -m pip install --user SomePackage [...] Requirement already satisfied (use --upgrade to upgrade) $ python -m pip install --user --upgrade SomePackage [...] Successfully installed SomePackage
Windows
C:\> py -m pip install --user SomePackage [...] Requirement already satisfied (use --upgrade to upgrade) C:\> py -m pip install --user --upgrade SomePackage [...] Successfully installed SomePackage
From within a real python, where SomePackage
is installed globally, and
is the latest version:
Unix/macOS
$ python -m pip install --user SomePackage [...] Requirement already satisfied (use --upgrade to upgrade) $ python -m pip install --user --upgrade SomePackage [...] Requirement already up-to-date: SomePackage # force the install $ python -m pip install --user --ignore-installed SomePackage [...] Successfully installed SomePackage
Windows
C:\> py -m pip install --user SomePackage [...] Requirement already satisfied (use --upgrade to upgrade) C:\> py -m pip install --user --upgrade SomePackage [...] Requirement already up-to-date: SomePackage # force the install C:\> py -m pip install --user --ignore-installed SomePackage [...] Successfully installed SomePackage
Ensuring Repeatability
This is now covered in Repeatable Installs.
Fixing conflicting dependencies
This is now covered in Dependency Resolution.
Using pip from your program¶
As noted previously, pip is a command line program. While it is implemented in
Python, and so is available from your Python code via import pip
, you must
not use pip’s internal APIs in this way. There are a number of reasons for this:
-
The pip code assumes that it is in sole control of the global state of the
program.
pip manages things like the logging system configuration, or the values of
the standard IO streams, without considering the possibility that user code
might be affected. -
pip’s code is not thread safe. If you were to run pip in a thread, there
is no guarantee that either your code or pip’s would work as you expect. -
pip assumes that once it has finished its work, the process will terminate.
It doesn’t need to handle the possibility that other code will continue to
run after that point, so (for example) calling pip twice in the same process
is likely to have issues.
This does not mean that the pip developers are opposed in principle to the idea
that pip could be used as a library — it’s just that this isn’t how it was
written, and it would be a lot of work to redesign the internals for use as a
library, handling all of the above issues, and designing a usable, robust and
stable API that we could guarantee would remain available across multiple
releases of pip. And we simply don’t currently have the resources to even
consider such a task.
What this means in practice is that everything inside of pip is considered an
implementation detail. Even the fact that the import name is pip
is subject
to change without notice. While we do try not to break things as much as
possible, all the internal APIs can change at any time, for any reason. It also
means that we generally won’t fix issues that are a result of using pip in an
unsupported way.
It should also be noted that installing packages into sys.path
in a running
Python process is something that should only be done with care. The import
system caches certain data, and installing new packages while a program is
running may not always behave as expected. In practice, there is rarely an
issue, but it is something to be aware of.
Having said all of the above, it is worth covering the options available if you
decide that you do want to run pip from within your program. The most reliable
approach, and the one that is fully supported, is to run pip in a subprocess.
This is easily done using the standard subprocess
module:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'my_package'])
If you want to process the output further, use one of the other APIs in the module.
We are using freeze here which outputs installed packages in requirements format.:
reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'])
To programmatically monitor download progress use the --progress-bar=raw
option.
This will print lines to stdout in the format Progress CURRENT of TOTAL
, where
CURRENT
and TOTAL
are integers and the unit is bytes.
If the real total is unknown then TOTAL
is set to 0
. Be aware that the
specific formatting of pip’s outputs are not guaranteed to be the same in future versions.
If you don’t want to use pip’s command line functionality, but are rather
trying to implement code that works with Python packages, their metadata, or
PyPI, then you should consider other, supported, packages that offer this type
of ability. Some examples that you could consider include:
-
packaging
— Utilities to work with standard package metadata (versions,
requirements, etc.) -
setuptools
(specificallypkg_resources
) — Functions for querying what
packages the user has installed on their system. -
distlib
— Packaging and distribution utilities (including functions for
interacting with PyPI).
Changes to the pip dependency resolver in 20.3 (2020)¶
pip 20.3 has a new dependency resolver, on by default for Python 3
users. (pip 20.1 and 20.2 included pre-release versions of the new
dependency resolver, hidden behind optional user flags.) Read below
for a migration guide, how to invoke the legacy resolver, and the
deprecation timeline. We also made a two-minute video explanation
you can watch.
We will continue to improve the pip dependency resolver in response to
testers’ feedback. Please give us feedback through the resolver
testing survey.
Watch out for¶
The big change in this release is to the pip dependency resolver
within pip.
Computers need to know the right order to install pieces of software
(“to install x
, you need to install y
first”). So, when Python
programmers share software as packages, they have to precisely describe
those installation prerequisites, and pip needs to navigate tricky
situations where it’s getting conflicting instructions. This new
dependency resolver will make pip better at handling that tricky
logic, and make pip easier for you to use and troubleshoot.
The most significant changes to the resolver are:
-
It will reduce inconsistency: it will no longer install a
combination of packages that is mutually inconsistent. In older
versions of pip, it is possible for pip to install a package which
does not satisfy the declared requirements of another installed
package. For example, in pip 20.0,pip install "six<1.12"
does the wrong thing, “successfully” installing
"virtualenv==20.0.2"
six==1.11
, even thoughvirtualenv==20.0.2
requires
six>=1.12.0,<2
(defined here).
The new resolver, instead, outright rejects installing anything if it
gets that input. -
It will be stricter — if you ask pip to install two packages with
incompatible requirements, it will refuse (rather than installing a
broken combination, like it did in previous versions).
So, if you have been using workarounds to force pip to deal with
incompatible or inconsistent requirements combinations, now’s a good
time to fix the underlying problem in the packages, because pip will
be stricter from here on out.
This also means that, when you run a pip install
command, pip only
considers the packages you are installing in that command, and may
break already-installed packages. It will not guarantee that your
environment will be consistent all the time. If you pip install x
and then pip install y
, it’s possible that the version of y
you get will be different than it would be if you had run pip
in a single command. We are considering changing this
install x y
behavior (per #7744) and would like your thoughts on what
pip’s behavior should be; please answer our survey on upgrades that
create conflicts.
We are also changing our support for Constraints Files,
editable installs, and related functionality. We did a fairly
comprehensive overhaul and stripped constraints files down to being
purely a way to specify global (version) limits for packages, and so
some combinations that used to be allowed will now cause
errors. Specifically:
-
Constraints don’t override the existing requirements; they simply
constrain what versions are visible as input to the resolver (see
#9020) -
Providing an editable requirement (
-e .
) does not cause pip to
ignore version specifiers or constraints (see #8076), and if
you have a conflict between a pinned requirement and a local
directory then pip will indicate that it cannot find a version
satisfying both (see #8307) -
Hash-checking mode requires that all requirements are specified as a
==
match on a version and may not work well in combination with
constraints (see #9020 and #8792) -
If necessary to satisfy constraints, pip will happily reinstall
packages, upgrading or downgrading, without needing any additional
command-line options (see #8115 and Options that control the installation process) -
Unnamed requirements are not allowed as constraints (see #6628 and #8210)
-
Links are not allowed as constraints (see #8253)
-
Constraints cannot have extras (see #6628)
Per our Python 2 Support policy, pip 20.3 users who are using
Python 2 will use the legacy resolver by default. Python 2 users
should upgrade to Python 3 as soon as possible, since in pip 21.0 in
January 2021, pip dropped support for Python 2 altogether.
How to upgrade and migrate¶
-
Install pip 20.3 with
python -m pip install --upgrade pip
. -
Validate your current environment by running
pip check
. This
will report if you have any inconsistencies in your set of installed
packages. Having a clean installation will make it much less likely
that you will hit issues with the new resolver (and may
address hidden problems in your current environment!). If you run
pip check
and run into stuff you can’t figure out, please ask
for help in our issue tracker or chat. -
Test the new version of pip.
While we have tried to make sure that pip’s test suite covers as
many cases as we can, we are very aware that there are people using
pip with many different workflows and build processes, and we will
not be able to cover all of those without your help.-
If you use pip to install your software, try out the new resolver
and let us know if it works for you withpip install
. Try:-
installing several packages simultaneously
-
re-creating an environment using a
requirements.txt
file -
using
pip install --force-reinstall
to check whether
it does what you think it should -
using constraints files
-
the “Setups to test with special attention” and “Examples to try” below
-
-
If you have a build pipeline that depends on pip installing your
dependencies for you, check that the new resolver does what you
need. -
Run your project’s CI (test suite, build process, etc.) using the
new resolver, and let us know of any issues. -
If you have encountered resolver issues with pip in the past,
check whether the new resolver fixes them, and read Dealing with dependency conflicts. Also, let us know if the new resolver
has issues with any workarounds you put in to address the
current resolver’s limitations. We’ll need to ensure that people
can transition off such workarounds smoothly. -
If you develop or support a tool that wraps pip or uses it to
deliver part of your functionality, please test your integration
with pip 20.3.
-
-
Troubleshoot and try these workarounds if necessary.
-
If pip is taking longer to install packages, read Dependency
resolution backtracking for ways to
reduce the time pip spends backtracking due to dependency conflicts. -
If you don’t want pip to actually resolve dependencies, use the
--no-deps
option. This is useful when you have a set of package
versions that work together in reality, even though their metadata says
that they conflict. For guidance on a long-term fix, read
Dealing with dependency conflicts. -
If you run into resolution errors and need a workaround while you’re
fixing their root causes, you can choose the old resolver behavior using
the flag--use-deprecated=legacy-resolver
. This will work until we
release pip 21.0 (see
Deprecation timeline).
-
-
Please report bugs through the resolver testing survey.
Setups to test with special attention¶
-
Requirements files with 100+ packages
-
Installation workflows that involve multiple requirements files
-
Requirements files that include hashes (Hash-checking Mode)
or pinned dependencies (perhaps as output frompip-compile
within
pip-tools
) -
Using Constraints Files
-
Continuous integration/continuous deployment setups
-
Installing from any kind of version control systems (i.e., Git, Subversion, Mercurial, or CVS), per VCS Support
-
Installing from source code held in local directories
Examples to try¶
Install:
-
tensorflow
-
hacking
-
pycodestyle
-
pandas
-
tablib
-
elasticsearch
andrequests
together -
six
andcherrypy
together -
pip install flake8-import-order==0.17.1 flake8==3.5.0 --use-feature=2020-resolver
-
pip install tornado==5.0 sprockets.http==1.5.0 --use-feature=2020-resolver
Try:
-
pip install
-
pip uninstall
-
pip check
-
pip cache
Tell us about¶
Specific things we’d love to get feedback on:
-
Cases where the new resolver produces the wrong result,
obviously. We hope there won’t be too many of these, but we’d like
to trap such bugs before we remove the legacy resolver. -
Cases where the resolver produced an error when you believe it
should have been able to work out what to do. -
Cases where the resolver gives an error because there’s a problem
with your requirements, but you need better information to work out
what’s wrong. -
If you have workarounds to address issues with the current resolver,
does the new resolver let you remove those workarounds? Tell us!
Please let us know through the resolver testing survey.
Deprecation timeline¶
We plan for the resolver changeover to proceed as follows, using
Feature Flags and following our Release Cadence:
-
pip 20.1: an alpha version of the new resolver was available,
opt-in, using the optional flag
--unstable-feature=resolver
. pip defaulted to legacy
behavior. -
pip 20.2: a beta of the new resolver was available, opt-in, using
the flag--use-feature=2020-resolver
. pip defaulted to legacy
behavior. Users of pip 20.2 who want pip to default to using the
new resolver can runpip config set global.use-feature
(for more on that and the alternate
2020-resolver
PIP_USE_FEATURE
environment variable option, see issue
8661). -
pip 20.3: pip defaults to the new resolver in Python 3 environments,
but a user can opt-out and choose the old resolver behavior,
using the flag--use-deprecated=legacy-resolver
. In Python 2
environments, pip defaults to the old resolver, and the new one is
available using the flag--use-feature=2020-resolver
. -
pip 21.0: pip uses new resolver by default, and the old resolver is
no longer supported. It will be removed after a currently undecided
amount of time, as the removal is dependent on pip’s volunteer
maintainers’ availability. Python 2 support is removed per our
Python 2 Support policy.
Since this work will not change user-visible behavior described in the
pip documentation, this change is not covered by the Deprecation Policy.
Attention
The legacy resolver is deprecated and unsupported. New features, such
as Installation Report, will not work with the
legacy resolver and this resolver will be removed in a future
release.
Context and followup¶
As discussed in our announcement on the PSF blog, the pip team are
in the process of developing a new “dependency resolver” (the part of
pip that works out what to install based on your requirements).
We’re tracking our rollout in #6536 and you can watch for
announcements on the low-traffic packaging announcements list and
the official Python blog.
Using system trust stores for verifying HTTPS
This is now covered in HTTPS Certificates.
Last Updated :
24 Nov, 2023
Python package is a container for storing multiple Python modules. We can install packages in Python using the pip package manager. In this article, we will learn to install multiple packages at once using the requirements.txt file. We will use the pip install requirements.txt command to install Python packages. The requirements.txt file is useful to install all packages at once for a project, it is easy to hand over to other developers and we can use this to install different versions of packages for different Python projects.
The classic way of installing packages in Python using pip:
pip install package_name1, package_name2
Installing Python Packages using requirements.txt file
Here, we will see how to install Python packages using pip install requirements.txt. We will define each package in a new line in the requirements.txt file.
Let’s say below the three Python packages we defined in the requirements.txt file.
- Pandas
- Pillow
- Numpy
We will install packages using the below command. Run the below command where the requirements.txt file is present.
pip install -r requirements.txt
PIP will download and install all packages present in that file.
Существует огромное количество пакетов Python, с помощью которых мы решаем задачи программирования на ежедневной основе. Возьмем, например, библиотеку Beautiful Soup. Она не встроена в Python по умолчанию, ее нужно устанавливать отдельно.
В основе многих проектов лежат библиотеки и всякие другие зависимости, и процесс установки каждой из них может оказаться довольно утомительным и времязатратным.
И вот тут-то в игру вступает файл requirements.txt – файл, содержащий список пакетов и библиотек, которые необходимы для работы с проектом и которые можно установить вместе с этим файлом. Это обеспечивает тот факт, что ваша среда будет согласованной, а совместная работа непринужденной.
Формат файла requirements.txt
Схема, показывающая поле, содержащее имя файла «requirements.txt», и поле под ним, содержащее основной текст вида «имя_пакета == версия»
На изображении, представленном выше, продемонстрирован образец созданного файла requirements.txt, который содержит список пакетов и версий их установки.
Ключевые понятия
Я уже успел упомянуть несколько понятий, с которыми вы, возможно, не знакомы. Ниже я расскажу, что они значат, а также упомяну и другие не менее важные термины, с которыми вы столкнетесь при работе с файлом requirements.txt:
- Зависимости – это программные компоненты, в которых нуждается программа для правильной работы. Это могут быть библиотеки, фреймворки и прочие программы.
- Пакеты – это способ группировки связанных зависимостей. С их помощью устанавливать и управлять зависимостями становится гораздо проще.
- Виртуальная среда – это каталог, который содержит копию интерпретатора Python и всех пакетов, необходимых для определенного проекта.
- Pip – это диспетчер пакетов для Python. Вы можете использовать его для того, чтобы устанавливать, удалять пакеты Python и управлять ими.
Как создать файл requirements.txt
Для того, чтобы создать файл requirements.txt, вам нужно настроить виртуальную среду. Если вы используете PyCharm, то виртуальная среда уже настроена (.venv). Но если вы работаете в Visual Studio Code, вам придется создать виртуальную среду самостоятельно.
Для создания файла requirements.txt вы можете использовать терминал или командную строку. Ниже приведены шаги, которые вам нужно выполнить, чтобы создать файл.
Для начала откройте терминал или командную строку. Далее проверьте, является ли указанный путь к файлу вашим рабочим каталогом. Для этого введите вот эту команду:
$ cd folder-name #cd - change directory
Замените в этой команде folder-name на имя каталога, к которому вы хотите получить доступ.
Настройка каталога проекта в командной строке
После чего запустите следующую команду:
$ pip freeze > requirements.txt
И вы увидите, что файл requirements.txt был добавлен:
Только что созданный файл requirements.txt
А вот так выглядит созданный файл requirements.txt внутри:
Список пакетов в файле requirements.txt
На изображении, представленном выше, продемонстрированы зависимости, с которыми вы можете работать, а также их версии.
Как работать с файлом requirements.txt
Теперь, когда у нас есть файл requirements.txt, вы можете увидеть, что внутри него находится длинный список различных пакетов.
Для того, чтобы работать с этими пакетами, вам нужно их установить. Вы можете это сделать через терминал или командную строку.
Введите вот эту команду:
pip install -r requirements.txt
И вы увидите примерно следующее:
Установка пакетов, находящихся в файле requirements.txt
Итак, все зависимости установлены, и теперь вы можете работать с файлом requirements.txt.
Пример использования файла requirements.txt
В этом примере мы будем работать с двумя библиотеками: beautifulsoup4 и requests. С их помощью мы будем извлекать информацию с сайта.
Рабочие библиотеки в файле requiremets.txt для данного примера
На изображении, представленном выше, вы видим, что в файле requirements.txt есть обе эти библиотеки, и, кроме того, указаны их версии. Так вот, раз мы установили их ранее, мы можем с ними работать.
- Импортируем библиотеку BeautifulSoup из пакета bs4 (beautifulsoup4). Также импортируем библиотеку requests.
from bs4 import BeautifulSoup
import requests
- Для того, чтобы получить информацию с веб-сайта по его URL-адресу, нам нужно подключиться к библиотеке requests, а для этого нам понадобиться метод .get().
web_data = requests.get("https://www.lithuania.travel/en/category/what-is-lithuania", headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"})
- Теперь, когда мы получили доступ к URL-адресу, библиотека BeautifulSoup принимает web_data и возвращает все содержимое HTML, которое в нем есть.
soup = BeautifulSoup(web_data.content, features="html.parser")
- В итоге я решил вернуть элементы с тегом <p>, который находится в позиции [0].
news_info = soup.findAll("p")[0]
print(news_info.text
Собираем все вместе:
from bs4 import BeautifulSoup
import requests
web_data = requests.get("https://www.lithuania.travel/en/category/what-is-lithuania", headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"})
soup = BeautifulSoup(web_data.content, features="html.parser")
news_info = soup.findAll("p")[0]
print(news_info.text)
И получим вот такой результат:
Код и результат
Плюсы использования файла requirements.txt
- Управление зависимостями: перечислив зависимости вашего проекта в файле requirements.txt, вы сможете легко понять, какие пакеты и какие версии вам нужны.
- Совместное использование вашего проекта с другими разработчиками: если вы делитесь своим проектом с другими разработчиками, вы можете добавить в него файл requirements.txt, чтобы они могли установить все необходимые пакеты. Это может сэкономить им время и нервы. Кроме того, это гарантирует тот факт, что все будут использовать одни и те же версии пакетов.
Заключение
Из этой статьи мы узнали, как можно создать файл requirements.txt, а также в чем преимущества его использования.
А еще я рекомендуют вам попробовать с ним поработать, а также добавить его к нескольким своим проектам.
Пройдите тест, узнайте какой профессии подходите
Иногда при работе с Python возникает необходимость установить пакеты из локального каталога, используя файл requirements.txt. Этот файл содержит список всех
Иногда при работе с Python возникает необходимость установить пакеты из локального каталога, используя файл requirements.txt. Этот файл содержит список всех пакетов, необходимых для работы проекта, и их версий. Пример содержимого такого файла:
BeautifulSoup==3.2.0
Django==1.3
Fabric==1.2.0
Jinja2==2.5.5
PyYAML==3.09
Pygments==1.4
SQLAlchemy==0.7.1
South==0.7.3
amqplib==0.6.1
anyjson==0.3
...
Такая ситуация часто возникает при работе с виртуальными окружениями, созданными с помощью инструмента virtualenv
. Это позволяет изолировать пакеты, необходимые для конкретного проекта, от глобальных пакетов Python.
Допустим, есть виртуальное окружение, созданное следующим образом:
bin/virtualenv testing
Чтобы активировать это окружение, используется команда:
source bin/activate
Теперь, чтобы установить пакеты из локального каталога в соответствии с файлом requirements.txt, используется команда pip:
pip install -r /path/to/requirements.txt -f file:///path/to/archive/
В результате выполнения этой команды pip попытается найти и установить все пакеты, указанные в файле requirements.txt, из локального каталога.
Однако, иногда после выполнения этой команды может возникнуть ситуация, когда пакеты, кажется, устанавливаются нормально, но при попытке их импортировать они не обнаруживаются, и они также отсутствуют в каталоге site-packages виртуального окружения. Это может быть связано с тем, что pip не смог правильно установить пакеты из локального каталога.
Чтобы решить эту проблему, можно попробовать следующие варианты:
-
Убедиться, что путь к локальному каталогу и файлу requirements.txt указаны правильно.
-
Убедиться, что все необходимые пакеты действительно присутствуют в локальном каталоге.
-
Убедиться, что виртуальное окружение активировано перед выполнением команды pip.
-
Попробовать переустановить пакеты с помощью pip, используя флаг —no-cache-dir, чтобы предотвратить использование кэшированных файлов пакетов:
pip install --no-cache-dir -r /path/to/requirements.txt -f file:///path/to/archive/
Эти рекомендации могут помочь успешно установить пакеты из локального каталога в соответствии с файлом requirements.txt.
This section covers the basics of how to install Python packages.
It’s important to note that the term “package” in this context is being used to
describe a bundle of software to be installed (i.e. as a synonym for a
distribution). It does not refer to the kind
of package that you import in your Python source code
(i.e. a container of modules). It is common in the Python community to refer to
a distribution using the term “package”. Using
the term “distribution” is often not preferred, because it can easily be
confused with a Linux distribution, or another larger software distribution
like Python itself.
Requirements for Installing Packages¶
This section describes the steps to follow before installing other Python
packages.
Ensure you can run Python from the command line¶
Before you go any further, make sure you have Python and that the expected
version is available from your command line. You can check this by running:
You should get some output like Python 3.6.3
. If you do not have Python,
please install the latest 3.x version from python.org or refer to the
Installing Python section of the Hitchhiker’s Guide to Python.
Note
If you’re a newcomer and you get an error like this:
>>> python3 --version Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'python3' is not defined
It’s because this command and other suggested commands in this tutorial
are intended to be run in a shell (also called a terminal or
console). See the Python for Beginners getting started tutorial for
an introduction to using your operating system’s shell and interacting with
Python.
Note
If you’re using an enhanced shell like IPython or the Jupyter
notebook, you can run system commands like those in this tutorial by
prefacing them with a !
character:
In [1]: import sys !{sys.executable} --version Python 3.6.3
It’s recommended to write {sys.executable}
rather than plain python
in
order to ensure that commands are run in the Python installation matching
the currently running notebook (which may not be the same Python
installation that the python
command refers to).
Note
Due to the way most Linux distributions are handling the Python 3
migration, Linux users using the system Python without creating a virtual
environment first should replace the python
command in this tutorial
with python3
and the python -m pip
command with python3 -m pip --user
. Do not
run any of the commands in this tutorial with sudo
: if you get a
permissions error, come back to the section on creating virtual environments,
set one up, and then continue with the tutorial as written.
Ensure you can run pip from the command line¶
Additionally, you’ll need to make sure you have pip available. You can
check this by running:
If you installed Python from source, with an installer from python.org, or
via Homebrew you should already have pip. If you’re on Linux and installed
using your OS package manager, you may have to install pip separately, see
Installing pip/setuptools/wheel with Linux Package Managers.
If pip
isn’t already installed, then first try to bootstrap it from the
standard library:
Unix/macOS
python3 -m ensurepip --default-pip
Windows
py -m ensurepip --default-pip
If that still doesn’t allow you to run python -m pip
:
-
Securely Download get-pip.py [1]
-
Run
python get-pip.py
. [2] This will install or upgrade pip.
Additionally, it will install Setuptools and wheel if they’re
not installed already.Warning
Be cautious if you’re using a Python install that’s managed by your
operating system or another package manager. get-pip.py does not
coordinate with those tools, and may leave your system in an
inconsistent state. You can usepython get-pip.py --prefix=/usr/local/
to install in/usr/local
which is designed for locally-installed
software.
Ensure pip, setuptools, and wheel are up to date¶
While pip
alone is sufficient to install from pre-built binary archives,
up to date copies of the setuptools
and wheel
projects are useful
to ensure you can also install from source archives:
Unix/macOS
python3 -m pip install --upgrade pip setuptools wheel
Windows
py -m pip install --upgrade pip setuptools wheel
Optionally, create a virtual environment¶
See section below for details,
but here’s the basic venv [3] command to use on a typical Linux system:
Unix/macOS
python3 -m venv tutorial_env source tutorial_env/bin/activate
Windows
py -m venv tutorial_env tutorial_env\Scripts\activate
This will create a new virtual environment in the tutorial_env
subdirectory,
and configure the current shell to use it as the default python
environment.
Creating Virtual Environments¶
Python “Virtual Environments” allow Python packages to be installed in an isolated location for a particular application,
rather than being installed globally. If you are looking to safely install
global command line tools,
see Installing stand alone command line tools.
Imagine you have an application that needs version 1 of LibFoo, but another
application requires version 2. How can you use both these applications? If you
install everything into /usr/lib/python3.6/site-packages (or whatever your
platform’s standard location is), it’s easy to end up in a situation where you
unintentionally upgrade an application that shouldn’t be upgraded.
Or more generally, what if you want to install an application and leave it be?
If an application works, any change in its libraries or the versions of those
libraries can break the application.
Also, what if you can’t install packages into the
global site-packages directory? For instance, on a shared host.
In all these cases, virtual environments can help you. They have their own
installation directories and they don’t share libraries with other virtual
environments.
Currently, there are two common tools for creating Python virtual environments:
-
venv is available by default in Python 3.3 and later, and installs
pip into created virtual environments in Python 3.4 and later
(Python versions prior to 3.12 also installed Setuptools). -
virtualenv needs to be installed separately, but supports Python 2.7+
and Python 3.3+, and pip, Setuptools and wheel are
installed into created virtual environments by default. Note thatsetuptools
is no longer
included by default starting with Python 3.12 (andvirtualenv
follows this behavior).
The basic usage is like so:
Using venv:
Unix/macOS
python3 -m venv <DIR> source <DIR>/bin/activate
Windows
py -m venv <DIR> <DIR>\Scripts\activate
Using virtualenv:
Unix/macOS
python3 -m virtualenv <DIR> source <DIR>/bin/activate
Windows
virtualenv <DIR> <DIR>\Scripts\activate
For more information, see the venv docs or
the virtualenv docs.
The use of source under Unix shells ensures
that the virtual environment’s variables are set within the current
shell, and not in a subprocess (which then disappears, having no
useful effect).
In both of the above cases, Windows users should not use the
source command, but should rather run the activate
script directly from the command shell like so:
Managing multiple virtual environments directly can become tedious, so the
dependency management tutorial introduces a
higher level tool, Pipenv, that automatically manages a separate
virtual environment for each project and application that you work on.
Use pip for Installing¶
pip is the recommended installer. Below, we’ll cover the most common
usage scenarios. For more detail, see the pip docs,
which includes a complete Reference Guide.
Installing from PyPI¶
The most common usage of pip is to install from the Python Package
Index using a requirement specifier. Generally speaking, a requirement specifier is
composed of a project name followed by an optional version specifier. A full description of the supported specifiers can be
found in the Version specifier specification.
Below are some examples.
To install the latest version of “SomeProject”:
Unix/macOS
python3 -m pip install "SomeProject"
Windows
py -m pip install "SomeProject"
To install a specific version:
Unix/macOS
python3 -m pip install "SomeProject==1.4"
Windows
py -m pip install "SomeProject==1.4"
To install greater than or equal to one version and less than another:
Unix/macOS
python3 -m pip install "SomeProject>=1,<2"
Windows
py -m pip install "SomeProject>=1,<2"
To install a version that’s compatible
with a certain version: [4]
Unix/macOS
python3 -m pip install "SomeProject~=1.4.2"
Windows
py -m pip install "SomeProject~=1.4.2"
In this case, this means to install any version “==1.4.*” version that’s also
“>=1.4.2”.
Source Distributions vs Wheels¶
pip can install from either Source Distributions (sdist) or Wheels, but if both are present
on PyPI, pip will prefer a compatible wheel. You can override
pip`s default behavior by e.g. using its –no-binary option.
Wheels are a pre-built distribution format that provides faster installation compared to Source
Distributions (sdist), especially when a
project contains compiled extensions.
If pip does not find a wheel to install, it will locally build a wheel
and cache it for future installs, instead of rebuilding the source distribution
in the future.
Upgrading packages¶
Upgrade an already installed SomeProject
to the latest from PyPI.
Unix/macOS
python3 -m pip install --upgrade SomeProject
Windows
py -m pip install --upgrade SomeProject
Installing to the User Site¶
To install packages that are isolated to the
current user, use the --user
flag:
Unix/macOS
python3 -m pip install --user SomeProject
Windows
py -m pip install --user SomeProject
For more information see the User Installs section
from the pip docs.
Note that the --user
flag has no effect when inside a virtual environment
— all installation commands will affect the virtual environment.
If SomeProject
defines any command-line scripts or console entry points,
--user
will cause them to be installed inside the user base’s binary
directory, which may or may not already be present in your shell’s
PATH
. (Starting in version 10, pip displays a warning when
installing any scripts to a directory outside PATH
.) If the scripts
are not available in your shell after installation, you’ll need to add the
directory to your PATH
:
-
On Linux and macOS you can find the user base binary directory by running
python -m site --user-base
and addingbin
to the end. For example,
this will typically print~/.local
(with~
expanded to the absolute
path to your home directory) so you’ll need to add~/.local/bin
to your
PATH
. You can set yourPATH
permanently by modifying ~/.profile. -
On Windows you can find the user base binary directory by running
py -m
and replacing
site --user-sitesite-packages
withScripts
. For
example, this could return
C:\Users\Username\AppData\Roaming\Python36\site-packages
so you would
need to set yourPATH
to include
C:\Users\Username\AppData\Roaming\Python36\Scripts
. You can set your user
PATH
permanently in the Control Panel. You may need to log out for the
PATH
changes to take effect.
Requirements files¶
Install a list of requirements specified in a Requirements File.
Unix/macOS
python3 -m pip install -r requirements.txt
Windows
py -m pip install -r requirements.txt
Installing from VCS¶
Install a project from VCS in “editable” mode. For a full breakdown of the
syntax, see pip’s section on VCS Support.
Unix/macOS
python3 -m pip install -e SomeProject @ git+https://git.repo/some_pkg.git # from git python3 -m pip install -e SomeProject @ hg+https://hg.repo/some_pkg # from mercurial python3 -m pip install -e SomeProject @ svn+svn://svn.repo/some_pkg/trunk/ # from svn python3 -m pip install -e SomeProject @ git+https://git.repo/some_pkg.git@feature # from a branch
Windows
py -m pip install -e SomeProject @ git+https://git.repo/some_pkg.git # from git py -m pip install -e SomeProject @ hg+https://hg.repo/some_pkg # from mercurial py -m pip install -e SomeProject @ svn+svn://svn.repo/some_pkg/trunk/ # from svn py -m pip install -e SomeProject @ git+https://git.repo/some_pkg.git@feature # from a branch
Installing from other Indexes¶
Install from an alternate index
Unix/macOS
python3 -m pip install --index-url http://my.package.repo/simple/ SomeProject
Windows
py -m pip install --index-url http://my.package.repo/simple/ SomeProject
Search an additional index during install, in addition to PyPI
Unix/macOS
python3 -m pip install --extra-index-url http://my.package.repo/simple SomeProject
Windows
py -m pip install --extra-index-url http://my.package.repo/simple SomeProject
Installing from a local src tree¶
Installing from local src in
Development Mode,
i.e. in such a way that the project appears to be installed, but yet is
still editable from the src tree.
Unix/macOS
python3 -m pip install -e <path>
Windows
py -m pip install -e <path>
You can also install normally from src
Unix/macOS
python3 -m pip install <path>
Windows
Installing from local archives¶
Install a particular source archive file.
Unix/macOS
python3 -m pip install ./downloads/SomeProject-1.0.4.tar.gz
Windows
py -m pip install ./downloads/SomeProject-1.0.4.tar.gz
Install from a local directory containing archives (and don’t check PyPI)
Unix/macOS
python3 -m pip install --no-index --find-links=file:///local/dir/ SomeProject python3 -m pip install --no-index --find-links=/local/dir/ SomeProject python3 -m pip install --no-index --find-links=relative/dir/ SomeProject
Windows
py -m pip install --no-index --find-links=file:///local/dir/ SomeProject py -m pip install --no-index --find-links=/local/dir/ SomeProject py -m pip install --no-index --find-links=relative/dir/ SomeProject
Installing from other sources¶
To install from other data sources (for example Amazon S3 storage)
you can create a helper application that presents the data
in a format compliant with the simple repository API:,
and use the --extra-index-url
flag to direct pip to use that index.
./s3helper --port=7777 python -m pip install --extra-index-url http://localhost:7777 SomeProject
Installing Prereleases¶
Find pre-release and development versions, in addition to stable versions. By
default, pip only finds stable versions.
Unix/macOS
python3 -m pip install --pre SomeProject
Windows
py -m pip install --pre SomeProject