找不到满足以下要求的版本:枕头==2.7.0

2024-05-19 08:12:00 发布

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

我有一个requirements.txt文件,行如下

Pillow==2.7.0

我下载了这样的离线模式的需求,并将其放入vendor director

pip install --download vendor -r requirements.txt

这将文件Pillow-2.7.0-cp27-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel下载到我的vendor目录

但当我尝试部署(推送)我的应用程序时,会出现以下错误:

   Collecting Pillow==2.7.0 (from -r requirements.txt (line 4))   
Could not find a version that satisfies the requirement Pillow==2.7.0 (from -r requirements.txt (line 4)) (from versions: ) 
No matching distribution found for Pillow==2.7.0 (from -r requirements.txt (line 4))

我正在使用Python Buildpack将应用程序部署到Cloud Foundry,遵循以下文档http://docs.cloudfoundry.org/buildpacks/python/index.html#vendoring


Tags: pip文件fromtxt应用程序部署line模式
2条回答

http://docs.cloudfoundry.org/buildpacks/python/index.html#vendoring的示例中,您可以看到以下注释

vendors all the pip *.tar.gz into vendor/

*.tar.gz包是源包,而pip的最新版本默认下载二进制包。若要强制pip仅下载源包,请使用--no-binary :all:如果要下载二进制包,则必须根据pip downloaddocumentation中的注释指定目标平台:

pip download with the --platform, --python-version, --implementation, and --abi options provides the ability to fetch dependencies for an interpreter and system other than the ones that pip is running on. --only-binary=:all: is required when using any of these options. It is important to note that these options all default to the current system/interpreter, and not to the most restrictive constraints (e.g. platform any, abi none, etc). To avoid fetching dependencies that happen to match the constraint of the current interpreter (but not your target one), it is recommended to specify all of these options if you are specifying one of them.

更新:另一篇文章指出了如何为pip的最新版本指定一个不提取二进制文件的标志(我假设这是问题所在)。如果这解决了问题,那么你应该选择他的职位作为解决方案。我也会戳cloudfoundry只是需要指出这一点。

--download选项只是下载依赖项的文件,而不是实际安装它(这可能是不推荐使用标志的原因,以消除这种混乱)。

pip download replaces the --download option to pip install, which is now deprecated and will be removed in pip 10.

和新的一样:

pip  download ....

https://pip.pypa.io/en/stable/reference/pip_download/

现在假设您的云提供商正在读取requirements.txt并在供应商文件夹中查找自己以进行安装(一种非明智的方法),那么您可能会遇到任何二进制文件、符号链接等方面的各种问题。。。除非要部署的环境与本地环境匹配。软件包系统(如pip和需求文件)的一部分思想是,不同的平台可以为其特定的体系结构、操作系统等提取所需的库。。。

这种方法有很多地方会出错。。。

例如,您的mac可能正在使用不区分大小写的文件系统。如果cloudfoundry使用的是linux,这是区分大小写的。在mac上,这并不重要,如果他们保存的都是小写的,但是当将文件复制到一个linux系统时,可能会出现一个问题,希望与大写的“P”匹配。

相关问题 更多 >

    热门问题