How to install/compile pip requirements in parallel (make -j equivalent)

我与影子孤独终老i 提交于 2021-01-23 06:15:23

问题


I have a lot of packages to install in my pip requirement and I'd like to process them in parallell.

I know that, for example, that if I want n parallel jobs from make I have to write make -j n; is there an equivalent command for pip requirements?

Thanks!


回答1:


Sometimes pip uses make to build dependencies. If before it starts you set MAKEFLAGS like:

export MAKEFLAGS="-j$(nproc)"
pip install -r requirements.txt

This may help building native dependencies.

Note: nproc resovles as the number of CPUs in your system.




回答2:


I think that the best approach to have a better speed is to see where is the bottleneck. Try to analyse which processes are taking place when you use pip command.

Probably the most time is spent downloading from PyPI and for compiling the libraries to native (such as PIL). You could try to make your own PyPI repository and to pre-compile the sources that are needed to be compiled. In the past there has been much talk of this but there isn't a really speed up if launching pip in parallel.



来源:https://stackoverflow.com/questions/26669244/how-to-install-compile-pip-requirements-in-parallel-make-j-equivalent

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