我正在尝试使用命令安装PIL (Python映像库):

sudo pip install pil

但我得到了以下信息:

Downloading/unpacking PIL
  You are installing a potentially insecure and unverifiable file. Future versions of pip will default to disallowing insecure files.
  Downloading PIL-1.1.7.tar.gz (506kB): 506kB downloaded
  Running setup.py egg_info for package PIL
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py
    
Installing collected packages: PIL
  Running setup.py install for PIL
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py
    --- using frameworks at /System/Library/Frameworks
    building '_imaging' extension
    clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -IlibImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.8-intel-2.7/_imaging.o
    unable to execute clang: No such file or directory
    error: command 'clang' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/private/tmp/pip_build_root/PIL/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-AYrxVD-record/install-record.txt --single-version-externally-managed:
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py

running install

running build

.
.
.
.

copying PIL/XVThumbImagePlugin.py -> build/lib.macosx-10.8-intel-2.7

running build_ext

--- using frameworks at /System/Library/Frameworks

building '_imaging' extension

creating build/temp.macosx-10.8-intel-2.7

creating build/temp.macosx-10.8-intel-2.7/libImaging

clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -IlibImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.8-intel-2.7/_imaging.o

unable to execute clang: No such file or directory

error: command 'clang' failed with exit status 1

----------------------------------------
Cleaning up…

你能帮我安装PIL吗?


当前回答

对于Ubuntu, PIL不再工作了。我总是得到:

PIL没有找到匹配的分布

安装python-imaging:

sudo apt-get install python-imaging

其他回答

这是非常简单的使用apt安装使用这个命令来完成

sudo apt-get install python-PIL

or

sudo pip install pillow

or

sudo easy_install pillow

还有另一个Python包工具叫做conda。当有库需要安装c++和其他非纯Python的绑定时,Conda比pip更可取(我相信)。Conda在其安装中也包含pip,因此您仍然可以使用pip,但也可以获得Conda的好处。

Conda还默认安装IPython、pil和许多其他库。我想你会喜欢的。

试试这个:

sudo pip install PIL --allow-external PIL --allow-unverified PIL

这些天,每个人都使用枕头,一个友好的PIL叉子,而不是PIL。

而不是:sudo pip安装pil

做:sudo pip装枕头

$ sudo apt-get install python-imaging
$ sudo -H pip install pillow

我试了所有的答案,但都失败了。 直接从官方站点获取源代码,然后构建安装成功。

访问http://www.pythonware.com/products/pil/#pil117网站 点击“Python Imaging Library 1.1.7 Source Kit”下载源代码 tar xf image -1.1.7.tar.gz cd Imaging-1.1.7 Sudo python setup.py安装