用pip安装PIL

本文翻译自:Installing PIL with pip

I am trying to install PIL (the Python Imaging Library) using the command: 我正在尝试使用以下命令安装PIL(Python Imaging Library):

sudo pip install pil

but I get the following message: 但我收到以下消息:

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…

Could you please help me to install PIL?? 您能帮我安装PIL吗?


#1楼

参考:https://stackoom.com/question/1MAXw/用pip安装PIL


#2楼

I take it you're on Mac. 我认为您在Mac上。 See How can I install PIL on mac os x 10.7.2 Lion 请参阅如何在Mac OS X 10.7.2 Lion上安装PIL

If you use [homebrew][], you can install the PIL with just brew install pil . 如果使用[homebrew] [],则可以仅通过brew install pil安装PIL。 You may then need to add the install directory ( $(brew --prefix)/lib/python2.7/site-packages ) to your PYTHONPATH, or add the location of PIL directory itself in a file called PIL.pth file in any of your site-packages directories, with the contents: 然后,您可能需要在PYTHONPATH中添加安装目录( $(brew --prefix)/lib/python2.7/site-packages ),或将PIL目录本身的位置添加到任何名为PIL.pth文件中您的site-packages目录,内容如下:

 /usr/local/lib/python2.7/site-packages/PIL 

(assuming brew --prefix is /usr/local ). (假设brew --prefix/usr/local )。

Alternatively, you can just download/build/install it from source: 另外,您也可以从源代码下载/构建/安装它:

 # download curl -O -L http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz # extract tar -xzf Imaging-1.1.7.tar.gz cd Imaging-1.1.7 # build and install python setup.py build sudo python setup.py install # or install it for just you without requiring admin permissions: # python setup.py install --user 

I ran the above just now (on OSX 10.7.2, with XCode 4.2.1 and System Python 2.7.1) and it built just fine, though there is a possibility that something in my environment is non-default. 我刚刚在OSX 10.7.2,XCode 4.2.1和System Python 2.7.1上运行了上面的代码,尽管它在我的环境中有可能不是默认值,但它的构建还不错。

[homebrew]: http://mxcl.github.com/homebrew/ "Homebrew" [homebrew]: http : //mxcl.github.com/homebrew/ “ Homebrew”


#3楼

  1. Install Xcode and Xcode Command Line Tools as mentioned. 如上所述安装Xcode和Xcode命令行工具。
  2. Use Pillow instead, as PIL is basically dead. 请改用Pillow,因为PIL基本已失效。 Pillow is a maintained fork of PIL. 枕头是PIL的保养品。

https://pypi.python.org/pypi/Pillow/2.2.1 https://pypi.python.org/pypi/Pillow/2.2.1

pip install Pillow

If you have both Pythons installed and want to install this for Python3: 如果您同时安装了两个Python,并且想要为Python3安装此代码,请执行以下操作:

python3 -m pip install Pillow

#4楼

I'm having the same problem, but it gets solved with installation of python-dev . 我遇到了同样的问题,但是通过安装python-dev可以解决。

Before installing PIL, run following command: 在安装PIL之前,请运行以下命令:

sudo apt-get install python-dev

Then install PIL: 然后安装PIL:

pip install PIL

#5楼

在Mac OS X上,使用以下命令:

sudo pip install https://effbot.org/media/downloads/Imaging-1.1.7.tar.gz

#6楼

This works for me: 这对我有用:

apt-get install python-dev
apt-get install libjpeg-dev
apt-get install libjpeg8-dev
apt-get install libpng3
apt-get install libfreetype6-dev
ln -s /usr/lib/i386-linux-gnu/libfreetype.so /usr/lib
ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib
ln -s /usr/lib/i386-linux-gnu/libz.so /usr/lib

pip install PIL  --allow-unverified PIL --allow-all-external

你可能感兴趣的:(python,python-2.7,installation,pip)