如何在本地下载pip依赖?

2024-04-29 12:16:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在运行我的python应用程序,它有包含各种依赖项的requirements.txt文件。我正在一个关键的Cloud Foundry环境中部署这个应用程序。然而,我在其中部署的环境是空的。因此,我似乎无法获得依赖关系。

python CF buildpack的Git repo建议,如果应用程序有一个vendor目录,那么它可能从那里获得依赖项:https://github.com/cloudfoundry/python-buildpack/blob/master/bin/steps/pip-install#L18

我的问题是,如何将requirements.txt文件中提到的依赖项本地下载到vendor文件夹中?


Tags: 文件gittxt应用程序cloud环境关系foundry
2条回答

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

tl;drpip install --download vendor -r requirements.txt

只需使用pip在dev框上安装,然后签入。

您可以使用以下命令获取所有依赖项(当然需要Internet连接)

pip download -r requirements.txt

然后,可以使用以下命令脱机安装这些依赖项

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 post

相关问题 更多 >