how to download pip dependencies locally? [duplicate]

纵饮孤独 提交于 2019-11-29 14:33:18

问题


I am running my python application that has requirements.txt file which contains various dependencies. I am deploying this application in a Pivotal Cloud Foundry environment. However, the environment I am deploying in it airgapped. Therefore I can't seem to get the dependencies.

The Git repo for python CF buildpack suggests that if an application has a vendor directory then it might get the dependencies from there: https://github.com/cloudfoundry/python-buildpack/blob/master/bin/steps/pip-install#L18

My question is, how can I download the dependencies mentioned in my requirements.txt file locally into a vendor folder?


回答1:


You can fetch all dependencies with the following command (an Internet connection is of course required)

pip download -r requirements.txt

Then, you can install offline those dependencies with the following command

pip install -r requirements.txt --no-index --find-links file:///tmp/packages

--no-index : Ignore package index (only looking at --find-links URLs instead).

-f, --find-links <URL> : If a URL or path to an html file, then parse for links to archives. If a local path or file:// URL that's a directory, then look for archives in the directory listing.

This answer is taken from this post




回答2:


Look at: http://docs.cloudfoundry.org/buildpacks/python/index.html#vendor-app-dependencies

tl;dr pip install --download vendor -r requirements.txt

Just use pip to install on the dev box and then check that in.



来源:https://stackoverflow.com/questions/44807039/how-to-download-pip-dependencies-locally

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