2016-12-26 177 views
6

我尝试安装PIL但出现错误,我该怎么办?尝试安装PIL时出现错误

$ Command 
Result 
------------ 
$ pip install PIL 

Collecting PIL 
    Could not find a version that satisfies the requirement PIL (from versions:) 
No matching distribution found for PIL 
-------------------------------------------------------------------- 
$ pip install PIL --allow-unverified PIL --allow-all-external 

DEPRECATION: --allow-all-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect. 
DEPRECATION: --allow-unverified has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect. 
Collecting PIL 
    Could not find a version that satisfies the requirement PIL (from versions:) 
No matching distribution found for PIL 
+0

什么系统?在Linux Mint上,你可以使用apt-get来安装python-pil或python-pillow – furas

回答

18

你可以尝试使用Pillow代替,这是一个PIL叉:

pip install Pillow 

要导入使用:

from PIL import Image 
+0

它的工作原理!谢谢! – Shira

0

不确定是否有比这更好的方法。但是这可以按照文档中所述的方式工作:

http://www.pythonware.com/products/pil/

下载源代码包并提取它。提取后,按照套件中的描述执行以下操作。

$ tar xvfz Imaging-1.1.7.tar.gz 
    $ cd Imaging-1.1.7 
    $ python setup.py install 
+0

从_imagingtk.c包含的文件中:19: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX .platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/tk.h:78:11:致命错误: 'X11/Xlib.h'文件未找到 #include ^ 生成1个错误。 错误:命令'cc'失败并退出状态1 – Shira

+0

看看这里有没有解决方案可以解决问题。 http://stackoverflow.com/questions/11465258/xlib-h-not-found-when-building-graphviz-on-mac-os-x-10-8-mountain-lion –

0

图书馆PILPillow。试试这个:

$ pip install Pillow