Python pip 安装 PIL 失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32772596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 12:13:16  来源:igfitidea点击:

pip install PIL fails

pythondjangopippython-imaging-library

提问by user3831214

I am trying to install the pip package PIL. However the install doesn't work throwing the following error.

我正在尝试安装 pip 包 PIL。但是安装不起作用,抛出以下错误。

Could not find a version that satisfies the requirement pil (from xhtml2pdf==0.0.4->-r virtualenv-reqs.txt (line 16)) (from versions: )
  Some externally hosted files were ignored as access to them may be unreliable (use --allow-external pil to allow).
No matching distribution found for pil (from xhtml2pdf==0.0.4->-r virtualenv-reqs.txt (line 16))

The install does work when I have an older version of pip, but with the current version of pip 7.1.2I am not able to download the package. I am using the following command to install the pip packages

当我有旧版本的 pip 时,安装确实有效,但使用当前版本的 pip7.1.2我无法下载包。我正在使用以下命令安装 pip 包

pip install --timeout=1000 -i http://pypi.ksjc.sh.colo/simple --trusted-host pypi.ksjc.sh.colo -r virtualenv-reqs.txt

What is the issue with this. I thought it might be an SSL issue which is why I added the --trusted-hostflag. Is there any way to the --allow-externalflag to be used with the virtualenv-reqsfile.

这有什么问题。我认为这可能是 SSL 问题,这就是我添加--trusted-host标志的原因。有没有办法将--allow-external标志与virtualenv-reqs文件一起使用。

回答by Hugo

Pillow is a maintained fork of PIL, so I recommend using Pillow. But you can't have both installed at the same time.

Pillow 是 PIL 的一个维护分支,所以我推荐使用 Pillow。但是您不能同时安装两者。

  1. First, remove both PIL and Pillow.

  2. Then install Pillow with pip install pillow(although, depending on platform, you may need some prerequisites).

  3. Then make sure code is using from PIL import Imagerather than import Image.

  1. 首先,取下 PIL 和 Pillow。

  2. 然后安装 Pillow pip install pillow(尽管根据平台,您可能需要一些先决条件)。

  3. 然后确保代码正在使用from PIL import Image而不是import Image.

回答by Rish

You can try using Pillowinstead, which is a PIL fork:

您可以尝试使用Pillow,它是一个 PIL 叉:

pip install Pillow

To import use following:

要导入使用以下内容:

from PIL import Image

回答by Jose Garza

One solution was, right-click on 'from PIL import Image' and click 'install Image'

一种解决方案是,右键单击“从 PIL 导入映像”并单击“安装映像”

I was on the PyCharm IDE.

我在 PyCharm IDE 上。

回答by BAKYAC

One solution that worked for me:

一种对我有用的解决方案:

By simply installing the latest version of Pillow using pip install -U PillowI can now call import PIL.Image

通过简单地安装最新版本的 Pillow,pip install -U Pillow我现在可以调用import PIL.Image