如何在本地下载pip依赖项? [英] how to download pip dependencies locally?

查看:213
本文介绍了如何在本地下载pip依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行具有requirements.txt文件的python应用程序,该文件包含各种依赖项.我正在Pivotal Cloud Foundry环境中部署此应用程序.但是,我在其中部署的环境是空白的.因此,我似乎无法获得依赖关系.

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.

针对python CF buildpack的Git存储库建议,如果应用程序具有vendor目录,则它可能会从那里获取依赖项:

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

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

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

推荐答案

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

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:忽略包索引(仅查看--find-links 网址).

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

-f, --find-links <URL>:如果URL或html文件的路径,则 解析到存档的链接.如果是目录的本地路径或file:// URL,则查找 在目录列表中存档.

-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.

此答案来自 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆