How can I do define multiple requirements files in my requirements.txt
file.
-r base.txt
-r test.txt
The current behavior is that pip
only installs packages from test.txt
. I'd expect pip to install packages found in both base.txt
and test.txt
. I could have sworn I've seen someone do this in the past, but I can't find any examples.
A Beginner's Guide to PipA requirements file is a list of all of a project's dependencies. This includes the dependencies needed by the dependencies. It also contains the specific version of each dependency, specified with a double equals sign ( == ). pip freeze will list the current projects dependencies to stdout .
txt. This is a safeguard against typos when running pip install -r requirements-dev. txt. If you leave out the -r by accident, this package will cause your installation to abort.
pip
accepts multiple -r
arguments:
pip install -r reqs1.txt -r reqs2.txt
The help for pip install
says:
-r, --requirement
Install from the given requirements file. This option can be used multiple times.
You can have one file "include" the other; for example, if you put this in file2.txt
:
-r file1.txt
Django
Flask
etc.
Then when you do pip install -r file2.txt
, it will also install things from file1.txt
.
I often use this strategy to have a "base" requirements file, and then only specify those things that are required at each stage (development, testing, staging, production, etc.)
I have many requirements in different directories and solve this problem as:
sudo find . -name "requirement*" -type f -exec pip3 install -r '{}' ';'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With