问题
I have a repository with an inflated requirements.tx that I'd like to clean up. Using pipreqs I've set my requirements.txt to be a minimal set of packages need for my repository. To test this, I setup a virtualenv to install the packages and then run all my unit tests to make sure they're satisfactory.
virtualenv temp_venv --no-site-packages
source temp_venv/bin/activate
pip install -r requirements.txt
Which runs fine, but I see that a whole bunch of extra packages are collected and installed. Why? Are these identified as needed by required packages, and thus installed? If so, should I then include them in the requirements.txt?
回答1:
Yes. The packages are dependencies of your dependencies.
But no, you should not specify them directly. Automatic tools know to download dependencies recursively and it would significantly add to maintenance overhead.
回答2:
This might have been because of the dependencies of your written libs in requirements.txt
. For ex: if you have written scipy
as requirement numpy
will also be installed because scipy
is dependent on numpy
.
来源:https://stackoverflow.com/questions/42919181/why-does-pip-install-requirements-txt-install-extra-packages