3

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
mathielo
  • 6,725
  • 7
  • 50
  • 63
Mikhaylova
  • 137
  • 4
  • 12

5 Answers5

2

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.

Community
  • 1
  • 1
mathielo
  • 6,725
  • 7
  • 50
  • 63
1

PIL is deprecated, use Pillow instead.

To install Pillow:

 pip install Pillow
Hugo
  • 27,885
  • 8
  • 82
  • 98
Riccardo
  • 1,490
  • 2
  • 12
  • 22
  • Thank you Riccardo, I tried this but again the same error...I wonder what this X-code is – Mikhaylova Dec 11 '14 at 17:38
  • @Mikhaylova did you install the X-code developer tools? – Riccardo Dec 11 '14 at 18:10
  • @Mikhaylova you can do it using the command 'xcode-select --install' from the terminal shell – Riccardo Dec 11 '14 at 18:11
  • following your instructions I successfully installed xcode, but I still have problems with Pillow, now it generates new errors when I try to install it. If you don't mind I can copy them here and maybe you can help me :) – Mikhaylova Dec 11 '14 at 18:46
  • @Mikhaylova ok update your question with the new errors – Riccardo Dec 11 '14 at 22:23
  • Did you uninstall PIL first? Try pip uninstall pil, then pip uninstall pillow, then brew install libtiff libjpeg webp little-cms2, then pip install pillow. See https://pillow.readthedocs.org/installation.html – Hugo Dec 13 '14 at 07:08
  • @Mikhaylova: Great! I've posted this as an answer for you. – Hugo Dec 13 '14 at 13:27
1

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.

Robert Lujo
  • 15,383
  • 5
  • 56
  • 73
Hugo
  • 27,885
  • 8
  • 82
  • 98
0

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.

Community
  • 1
  • 1
0

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

Klas Mellbourn
  • 42,571
  • 24
  • 140
  • 158