简体   繁体   中英

Error installing PIL library for Python

After installing xcode I executed pip install Pillow and the last code strings say:

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

The actual problem is that Xcode's Command Line Tools is missing. To fix it, just run

xcode-select --install

on your terminal. A dialog will pop up, accept and Xcode's CLT will be installed.

See it here .

PIL is deprecated, use Pillow instead.

To install Pillow:

 pip install Pillow

Did you uninstall PIL first?

Try:

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

See https://pillow.readthedocs.io/en/stable/installation.html for more information.

Install XQuartz .

X (or X11 ) is a (the default) *nix window system, which some *nix software that can be compiled on a Mac relies upon.

The problem appears to be that PIL and Pillow appear to assume you want Tk(inter) , which in turns relies on X . If you don't want fancy dialog stuff for your image processing, there should be a way to turn that off, though that may require a manual installation.

Alternatively, perhaps this answer may be of use; but that still requires X to be installed, and just fixes a bad link.

Installing SDK headers worked for me

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

For more information see https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes#3035624

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM