Skip to main content
 首页 » 编程设计

python之找不到满足 Pillow==2.7.0 要求的版本

2024年10月17日9mfrbuaa

我有一个包含以下行的 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

请您参考如下方法:

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

--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 并在您的供应商文件夹中查找自己以进行安装(一种不太明智的方法),您可能会遇到任何二进制文件、符号链接(symbolic link)的各种问题等等...除非您要部署的环境与本地环境相匹配。像 pip 和需求文件这样的包系统的部分想法是,不同的平台可以为他们的特定架构、操作系统等提取所需的库......

这种方法有很多地方可能出错...

例如,您的 Mac 可能正在使用不区分大小写的文件系统。如果 cloudfoundry 使用 linux,则区分大小写。在 Mac 上,如果他们将其全部保存为小写,这并不重要,但在将文件复制到期望匹配大写“P”的 Linux 系统时可能会出现问题。