安装Python的PIL库时出错

问题描述 投票:2回答:5

安装xcode后我执行了pip install Pillow,最后的代码字符串说:

In file included from _imagingtk.c:19:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found

In file included from Tk/tkImaging.c:52:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found
#       include <X11/Xlib.h>
                ^

1 error generated.
1 error generated.

Building using 4 processes

cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.9-intel-2.7/_imagingtk.o build/temp.macosx-10.9-intel-2.7/Tk/tkImaging.o -L/System/Library/Frameworks/Python.framework/Versions/2.7/lib -L/usr/X11/lib -L/usr/lib -o build/lib.macosx-10.9-intel-2.7/PIL/_imagingtk.so -framework Tcl -framework Tk

clang: error: no such file or directory: 'build/temp.macosx-10.9-intel-2.7/_imagingtk.o'

clang: error: no such file or directory: 'build/temp.macosx-10.9-intel-2.7/Tk/tkImaging.o'

error: command 'cc' failed with exit status 1
----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build/Pillow/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-YMhwsU-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build/Pillow
Storing complete log in /var/root/Library/Logs/pip.log
python xcode python-imaging-library failed-installation
5个回答
0
投票

你先卸载PIL了吗?

尝试:

pip uninstall pil
pip uninstall pillow
brew install libtiff libjpeg webp little-cms2
pip install pillow

有关更多信息,请参阅http://pillow.readthedocs.org/installation.html


2
投票

实际问题是缺少Xcode的命令行工具。要解决它,只需运行

xcode-select --install

在你的终端上。将弹出一个对话框,接受并安装Xcode的CLT。

看到它here


1
投票

不推荐使用PIL,而是使用Pillow。

要安装枕头:

 pip install Pillow

0
投票

安装XQuartz

X(或X11)是一个(默认的)* nix窗口系统,可以在Mac上编译的某些* nix软件依赖于它。

问题似乎是PIL和Pillow似乎假设你想要Tk(inter),而X又依赖于this answer。如果您不想为图像处理提供花哨的对话框,那么应该有办法将其关闭,尽管这可能需要手动安装。

或者,也许X可能有用;但仍然需要安装sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / ,并修复一个不好的链接。


0
投票

安装SDK标头对我有用

https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes#3035624

有关更多信息,请参阅qazxswpoi

© www.soinside.com 2019 - 2024. All rights reserved.