pip安装PIL失败

时间:2015-09-24 23:36:26

标签: python django pip python-imaging-library

我正在尝试安装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))

当我有旧版本的pip时,安装确实有效,但是当前版本的pip 7.1.2我无法下载该软件包。我使用以下命令安装pip包

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

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

4 个答案:

答案 0 :(得分:61)

Pillow是PIL的维护叉,所以我推荐使用Pillow。但是你不能同时安装这两个。

  1. 首先,移除PIL和Pillow。

  2. 然后使用pip install pillow安装Pillow(尽管根据平台,您可能需要一些prerequisites)。

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

答案 1 :(得分:0)

您可以改用Pillow,它是PIL分支:

pip install Pillow

要导入,请使用以下内容:

from PIL import Image

答案 2 :(得分:0)

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

我当时在使用PyCharm IDE。

答案 3 :(得分:0)

我正在使用PyCharm IDE,但遇到了这个问题。我只是将鼠标悬停在“ PIL”上,然后弹出一个小窗口。我单击了更多操作,然后出现几个选项。我单击“安装枕头,然后问题解决。

相关问题