Why does pip install requirements.txt install extra packages?

橙三吉。 提交于 2021-02-05 11:15:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!