Can't install PIL after Mac OS X 10.9

93,477

Solution 1

Following worked for me:

ln -s  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 /usr/local/include/X11
sudo pip install pil

UPDATE:

But there is more correct solution below, provided by Will.

open your terminal and execute: xcode-select --install

Solution 2

open your terminal and execute:

xcode-select --install

Solution 3

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11/ /usr/local/include/X11

helps for me! os x 10.9

pip install pillow

but! after pip install ...

*** ZLIB (PNG/ZIP) support not available

and finally i fix it by running:

xcode-select --install

then reinstall pillow

pip install pillow

PIL SETUP SUMMARY
    --------------------------------------------------------------------
    version      Pillow 2.2.1
    platform     darwin 2.7.5 (default, Aug 25 2013, 00:04:04)
                 [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
    --------------------------------------------------------------------
    --- TKINTER support available
    --- JPEG support available
    --- ZLIB (PNG/ZIP) support available
    --- TIFF G3/G4 (experimental) support available
    --- FREETYPE2 support available
    --- LITTLECMS support available
    --- WEBP support available
    --- WEBPMUX support available
    --------------------------------------------------------------------

Solution 4

Works for me ( OS X Yosemite 10.10.2 - Python 2.7.9 ) :

xcode-select --install
sudo pip install pillow

Try this to check it:

from PIL import Image
image = Image.open("file.jpg")
image.show()

Solution 5

Here is what I did, some steps may not be necessary just for PIL but I needed libpng and others anyways:

1) Run xcode install, use this command or download updates from the app store:

xcode-select --install

1b) Add the Command Line Tools optional tool, in Mountain Lion this was an option on the xcode Download page, but now you have to register with your apple id and download from: https://developer.apple.com/downloads/

Look for Command Line Tools (OS X Mavericks) for Xcode

2) Install everything needed for python (using brew), I believe you can use port as well:

brew install readline sqlite gdbm
brew install python --universal --framework 
brew install libpng jpeg freetype

Unlink/ relink if needed i.e. if upgrading.

3) Install Pip and required modules:

easy_install pip 
sudo pip install setuptools --no-use-wheel --upgrade

4) Finally this works with no errors:

sudo pip install Pillow

UPDATE 11/04/14: PIL repo no longer receives updates or support so Pillow should be used. The below is now deprecated so stick with Pillow.

sudo pip install pil --allow-external pil --allow-unverified pil

UPDATE (OLD) : The same thing applies when installing Pillow (PIL fork) and should be mentioned as its quickly becoming a replacement in most cases of PIL. Instead of installing pip in step 4, run this instead:

sudo pip install Pillow

Hope this helps someone!

Share:
93,477
Vincent Audebert
Author by

Vincent Audebert

React / Redux lover Working remotely. Check my LinkedIn profile for up-to-date information: https://www.linkedin.com/in/vincentaudebert/

Updated on November 13, 2020

Comments

  • Vincent Audebert
    Vincent Audebert over 3 years

    I've just updated my Mac OS to 10.9 and I discovered that some (all?) of my Python modules are not here anymore, especially the Image one.

    So I try to execute sudo pip install pil, but I get this error:

    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found
    
    #      include <X11/Xlib.h>
    
                   ^
    
    1 error generated.
    
    error: command 'cc' failed with exit status 1
    

    My Xcode is up-to-date and I don't have any idea. Is it possible that PIL is not yet 10.9 compatible ?

  • bonbon.langes
    bonbon.langes over 10 years
    not working for me... did you update your xcode before making it to work? did you restart your mac lots of times? this is frustrating me. ughs.
  • Vincent Audebert
    Vincent Audebert over 10 years
    I did my xcode update before and I restarted my mac even if I'm not sure it's helpful. Maybe the path to your X11 is not the same for you. Try some of the other answers maybe.
  • javiercf
    javiercf over 10 years
    updated to mavericks yesterday and just today I was starting a project, you just saved me hours of heartache THANKS!
  • Bryan Veloso
    Bryan Veloso over 10 years
    Your answer has a typo, it's MacOS10.9.sdk not MacOS0.9.sdk.
  • Soravux
    Soravux over 10 years
    A similar answer was given and accepted two weeks ago. I fail to see the additional value of yours...
  • Vincent Audebert
    Vincent Audebert over 10 years
    The question is not about installing Xcode but PIL... Moreover, I explained that I already had Xcode installed and up-to-date.
  • gromgull
    gromgull over 10 years
    If you also want to have a PIL/Pillow with zlib/png/zip support you also need to do: ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.‌​platform/Developer/S‌​DKs/MacOSX10.9.sdk/u‌​sr/include/zlib.h /usr/local/include/
  • tatlar
    tatlar over 10 years
    I definitely prefer this approach. I hate doing custom symlinking with system packages... you never know what is going to break on the next update...
  • Rob Osborne
    Rob Osborne over 10 years
    This solves the problem as well (it install the command line tools that are not installed by default with Xcode).
  • joerick
    joerick over 10 years
    This is all I needed to do, none of that symlinking stuff.
  • Sergey Orshanskiy
    Sergey Orshanskiy over 10 years
    If it does not work, try slightly different directories: sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.‌​platform/Developer/S‌​DKs/MacOSX10.9.sdk/S‌​ystem/Library/Framew‌​orks/Tk.framework/Ve‌​rsions/8.5/Headers/X‌​11 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.‌​platform/Developer/S‌​DKs/MacOSX10.9.sdk/u‌​sr/include/X11 and then sudo pip install Pillow
  • Sergey Orshanskiy
    Sergey Orshanskiy over 10 years
    Well, this answer has different paths than the accepted one. I added this version as a comment to the accepted answer. The command is sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.‌​platform/Developer/S‌​DKs/MacOSX10.9.sdk/S‌​ystem/Library/Framew‌​orks/Tk.framework/Ve‌​rsions/8.5/Headers/X‌​11 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.‌​platform/Developer/S‌​DKs/MacOSX10.9.sdk/u‌​sr/include/X11
  • Jehiah
    Jehiah over 10 years
    instead of making symlinks installing the command line tools (as suggested in another answer) fixes the solution properly.
  • Matt Feifarek
    Matt Feifarek over 10 years
    That appears to be a bad URL now.
  • Matt Feifarek
    Matt Feifarek over 10 years
    the suggested command brings up an error dialog from Apple. First it asks whether I want to Get XCode (which I have) or "Install". I choose install. It pops up a EULA, I accept, then an error dialog comes up: "Can't install the software because it is not currently available from the Software Update server."
  • Casebash
    Casebash over 10 years
    @MattFeifarek: Try looking at this thread
  • Matt
    Matt about 10 years
    The "More Correct Solution" did not work for me (in fact the command line tools were already installed in the normal way, so I got the same error as in @MattFeifarek's comment). But the symlink did fix the problem (allowing X11/Xlib.h to be found). So I think the second solution is only a more correct solution if it works! For the rest of us, the symlink is the better solution.
  • Leonid
    Leonid about 10 years
    I encountered an error Downloading/unpacking pil Could not find any downloads that satisfy the requirement pil Some externally hosted files were ignored (use --allow-external pil to allow). Cleaning up... No distributions at all found for pil Storing debug log for failure in /Users/Usermania/.pip/pip.log
  • riley chen
    riley chen about 10 years
    This I had to do $> ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error‌​-in-future pip install pillow
  • pigletfly
    pigletfly about 10 years
    ln: /usr/local/include/X11: No such file or directory I have no /usr/local/include/X11 direcotry?
  • Tony Adams
    Tony Adams about 10 years
    @VincentShowcaseWorkshop Xcode does not install the command line tools by default. I had to do this to get past the same problem as the OP's even though I most definitely already had Xcode installed and up to date on Mac OS 10.9.2.
  • Tony Adams
    Tony Adams about 10 years
    @MattFeifarek that URL worked for me today. I had to log in with a dev account, but it then took me to the relevant command line tools download page.
  • Eric
    Eric almost 10 years
    This is the one that fixed it for me. If you are running a virtual enviroment, you do not need the sudo command.
  • 0xmtn
    0xmtn almost 10 years
    Hello rchapman. When I run brew to install samueljohn/python/pillow, it gives a warning like: pillow-2.5.1 already installed, it's just not linked. And before this, there are 15 warnings like: Could not tap homebrew/python/cpyrit-cuda over samueljohn/python/cpyrit-cuda. Any ideas why this happens? Or how can I link pillow?
  • Jamie Counsell
    Jamie Counsell almost 10 years
    Thank you! This works running a Python virtual environment. I didn't have Xcode currently installed so this saved me the download time.
  • radtek
    radtek over 9 years
    You still need all the pre-config as you would for PIL
  • radtek
    radtek over 9 years
    I was able to install it without command line tools using the Xcode for Mavericks.
  • radtek
    radtek over 9 years
    This works great for old xcode in 10.8, did it work for Mavericks?
  • Bobo
    Bobo over 9 years
    @radtek no you don't on mac 10.9. Have you actually tried the command before you down-voted my answer?
  • radtek
    radtek over 9 years
    I didn't downvote ur answer, i upvoted, but yeah I did try. I actually did this a few times now and I didn't need step 1b actually but everything else I needed.
  • Sir l33tname
    Sir l33tname over 9 years
    Please add a bit more, and explain why he should do that.
  • Raffi
    Raffi over 9 years
    Works also for Yosemite OSX 10.10
  • Bugs Bunny
    Bugs Bunny over 9 years
    Step 4) may end with sth like _imagingft.c:73:10: fatal error: 'freetype/fterrors.h' file not found. But could be resolved following stackoverflow.com/questions/20325473/….
  • radtek
    radtek over 9 years
    are you installing pil or pillow? PIL is deprecated, I'll update this.
  • Bugs Bunny
    Bugs Bunny over 9 years
    Doesn't matter. PIL or Pillow, it might still be useful for some poeple to resolve symlinking freetype/freetype2 issue. But thanks!
  • radtek
    radtek over 9 years
    Yeah I added stuff in step 2 for unlink /link if upgrading. If missing something can you edit and I'll accept?
  • tamasgal
    tamasgal over 9 years
    Don't mess around with symlinks, run xcode-select --install and you're fine. (as Will mentioned)
  • fun_vit
    fun_vit over 9 years
    sudo pip install pil --allow-external pil --allow-unverified pil helped me in 2015
  • Paul Kenjora
    Paul Kenjora over 9 years
    USE THE UPDATE METHOD: xcode-select --install WORKS!
  • rozochkin
    rozochkin about 9 years
    thanks! for 10.10 use: sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.‌​platform/Developer/S‌​DKs/MacOSX10.10.sdk/‌​System/Library/Frame‌​works/Tk.framework/V‌​ersions/8.5/Headers/‌​X11 /usr/local/include/X11
  • Big Rich
    Big Rich over 8 years
    Although xcode-select --installis helpful, I still had to symlink X11 issuing ln -s /opt/X11/include/X11 /usr/local/include/X11 - JFYI, I was trying to build Dlib using the included Cmake file (examples), on El Captian (OSX 10.11.1).
  • webtweakers
    webtweakers over 8 years
    This fixes the issue with Mac version 10.11.2 (15C50).
  • Most Wanted
    Most Wanted about 5 years
    ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/L‌​ibrary/Frameworks/Tk‌​.framework/Versions/‌​8.5/Headers/X11 /usr/local/include/X11 worked on MacOS Mojave 10.14