问题:用pip安装PIL
我正在尝试使用以下命令安装PIL(Python Imaging Library):
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吗?
I am trying to install PIL (the Python Imaging Library) using the command:
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??
回答 0
- Install Xcode and Xcode Command Line Tools as mentioned.
- Use Pillow instead, as PIL is basically dead. Pillow is a maintained fork of PIL.
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:
python3 -m pip install Pillow
回答 1
这对我有用:
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
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
回答 2
使用apt install非常简单,使用此命令即可完成
sudo apt-get install python-PIL
要么
sudo pip install pillow
要么
sudo easy_install pillow
It is very simple using apt install use this command to get it done
sudo apt-get install python-PIL
or
sudo pip install pillow
or
sudo easy_install pillow
回答 3
在Mac OS X上,使用以下命令:
sudo pip install https://effbot.org/media/downloads/Imaging-1.1.7.tar.gz
On Mac OS X, use this command:
sudo pip install https://effbot.org/media/downloads/Imaging-1.1.7.tar.gz
回答 4
您应该描述安装在这里:
pip install image
You should install as described here:
pip install image
回答 5
我从这里的讨论中得到了答案:
我试过了
pip install --no-index -f http://dist.plone.org/thirdparty/ -U PIL
而且有效。
I got the answer from a discussion here:
I tried
pip install --no-index -f http://dist.plone.org/thirdparty/ -U PIL
and it worked.
回答 6
安装
pip install Pillow
然后,只需导入文件,例如
from PIL import Image
我正在使用Windows。它为我工作。
注意:
Pillow是Python Imaging Library的功能替代品。要使用Pillow运行现有的PIL兼容代码,需要对其进行修改以从PIL命名空间而不是全局命名空间导入Imaging模块。
即更改:
import Image
至:
from PIL import Image
https://pypi.org/project/枕头/2.2.1/
Install
pip install Pillow
Then, Just import in your file like,
from PIL import Image
I am using windows. It is working for me.
NOTE:
Pillow is a functional drop-in replacement for the Python Imaging
Library. To run your existing PIL-compatible code with Pillow, it
needs to be modified to import the Imaging module from the PIL
namespace instead of the global namespace.
i.e. change:
import Image
to:
from PIL import Image
https://pypi.org/project/Pillow/2.2.1/
回答 7
我认为您在Mac上。请参阅如何在Mac OS X 10.7.2 Lion上安装PIL
如果使用[homebrew] [],则可以使用just安装PIL brew
install pil
。然后,您可能需要将安装目录($(brew
--prefix)/lib/python2.7/site-packages
)添加到PYTHONPATH中,或者将PIL目录本身的位置添加到PIL.pth
任何site-packages目录中名为file的文件中,内容如下:
/usr/local/lib/python2.7/site-packages/PIL
(假设brew --prefix
为/usr/local
)。
另外,您也可以从源代码下载/构建/安装它:
# 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
我刚刚(在OSX 10.7.2,XCode 4.2.1和System Python 2.7.1上)运行了上面的代码,尽管在我的环境中某些内容可能不是默认值,但它的构建还不错。
[homebrew]:http : //mxcl.github.com/homebrew/ “ Homebrew”
I take it you’re on Mac. See How can I install PIL on mac os x 10.7.2 Lion
If you use [homebrew][], you can install the PIL with just brew
install 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:
/usr/local/lib/python2.7/site-packages/PIL
(assuming brew --prefix
is /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.
[homebrew]: http://mxcl.github.com/homebrew/ “Homebrew”
回答 8
如今,每个人都在PIL上使用友好的PIL叉子Pillow。
代替: sudo pip install pil
做: sudo pip install pillow
$ sudo apt-get install python-imaging
$ sudo -H pip install pillow
These days, everyone uses Pillow, a friendly PIL fork, over PIL.
Instead of: sudo pip install pil
Do: sudo pip install pillow
$ sudo apt-get install python-imaging
$ sudo -H pip install pillow
回答 9
对于Ubuntu,PIL不再起作用。我总是得到:
找不到与PIL匹配的分布
因此,安装python-imaging:
sudo apt-get install python-imaging
For Ubuntu, PIL is not working any more. I always get:
No matching distribution found for PIL
So install python-imaging:
sudo apt-get install python-imaging
回答 10
我遇到了同样的问题,但是通过安装 python-dev
。
在安装PIL之前,请运行以下命令:
sudo apt-get install python-dev
然后安装PIL:
pip install PIL
I’m having the same problem, but it gets solved with installation of python-dev
.
Before installing PIL, run following command:
sudo apt-get install python-dev
Then install PIL:
pip install PIL
回答 11
安装过程中出现了一些错误。以防万一有人也有这个。尽管我已经是管理员用户,但不是root用户。
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/PIL'
Storing debug log for failure in /Users/wzbozon/Library/Logs/pip.log
添加“ sudo”解决了问题,使用sudo可以解决问题:
~/Documents/mv-server: $ sudo pip install Pillow
I had some errors during installation. Just in case somebody has this too. Despite that I already was sitting under admin user, but not root.
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/PIL'
Storing debug log for failure in /Users/wzbozon/Library/Logs/pip.log
Adding “sudo” solved the problem, with sudo it worked:
~/Documents/mv-server: $ sudo pip install Pillow
回答 12
对于CentOS:
yum install python-imaging
For CentOS:
yum install python-imaging
回答 13
I tried all the answers, but failed.
Directly get the source from the official site and then build install success.
- Go to the site http://www.pythonware.com/products/pil/#pil117
- Click “Python Imaging Library 1.1.7 Source Kit” to download the source
tar xf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7
sudo python setup.py install
回答 14
我用 sudo port install py27-Pillow
I nailed it by using sudo port install py27-Pillow
回答 15
尝试这个:
sudo pip install PIL --allow-external PIL --allow-unverified PIL
Try this:
sudo pip install PIL --allow-external PIL --allow-unverified PIL
回答 16
回答 17
首先,您应该运行此程序sudo apt-get build-dep python-imaging
,它将为您提供可能需要的所有依赖项
然后跑 sudo apt-get update && sudo apt-get -y upgrade
其次是 sudo apt-get install python-pip
然后最后安装Pil pip install pillow
First you should run this sudo apt-get build-dep python-imaging
which will give you all the dependencies that you might need
Then run sudo apt-get update && sudo apt-get -y upgrade
Followed by sudo apt-get install python-pip
And then finally install Pil pip install pillow
回答 18
使用之前,请先搜索软件包管理器pip
。在Arch Linux上,您可以通过以下方式获取PIL:pacman -S python2-pillow
Search on package manager before using pip
. On Arch linux you can get PIL by pacman -S python2-pillow
回答 19
还有另一个名为的Python打包工具conda
。当某些库需要安装C ++和其他非纯Python的绑定时,Conda优于pip(我认为)。Conda的安装中还包括点子,因此您仍然可以使用点子,但您也可以从conda中受益。
默认情况下,Conda还安装IPython,pil和许多其他库。我想你会喜欢的。
There’s another Python package tool called conda
. Conda is preferred (I believe) over pip when there are libraries that need to install C++ and other bindings that aren’t pure Python. Conda includes pip in its installation as well so you can still use pip, but you also get the benefits of conda.
Conda also installs IPython, pil, and many other libraries by default. I think you’ll like it.