Can't install PIL after Mac OS X 10.9
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!
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, 2020Comments
-
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 over 10 yearsnot 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 over 10 yearsI 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 over 10 yearsupdated to mavericks yesterday and just today I was starting a project, you just saved me hours of heartache THANKS!
-
Bryan Veloso over 10 yearsYour answer has a typo, it's
MacOS10.9.sdk
notMacOS0.9.sdk
. -
Soravux over 10 yearsA similar answer was given and accepted two weeks ago. I fail to see the additional value of yours...
-
Vincent Audebert over 10 yearsThe question is not about installing Xcode but PIL... Moreover, I explained that I already had Xcode installed and up-to-date.
-
gromgull over 10 yearsIf 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/SDKs/MacOSX10.9.sdk/usr/include/zlib.h /usr/local/include/
-
tatlar over 10 yearsI 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 over 10 yearsThis solves the problem as well (it install the command line tools that are not installed by default with Xcode).
-
joerick over 10 yearsThis is all I needed to do, none of that symlinking stuff.
-
Sergey Orshanskiy over 10 yearsIf it does not work, try slightly different directories:
sudo 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 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/X11
and thensudo pip install Pillow
-
Sergey Orshanskiy over 10 yearsWell, 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/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/X11
-
Jehiah over 10 yearsinstead of making symlinks installing the command line tools (as suggested in another answer) fixes the solution properly.
-
Matt Feifarek over 10 yearsThat appears to be a bad URL now.
-
Matt Feifarek over 10 yearsthe 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 over 10 years@MattFeifarek: Try looking at this thread
-
Matt about 10 yearsThe "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 about 10 yearsI 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 about 10 yearsThis I had to do $> ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pillow
-
pigletfly about 10 yearsln: /usr/local/include/X11: No such file or directory I have no /usr/local/include/X11 direcotry?
-
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 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 almost 10 yearsThis is the one that fixed it for me. If you are running a virtual enviroment, you do not need the sudo command.
-
0xmtn almost 10 yearsHello 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 almost 10 yearsThank you! This works running a Python virtual environment. I didn't have Xcode currently installed so this saved me the download time.
-
radtek over 9 yearsYou still need all the pre-config as you would for PIL
-
radtek over 9 yearsI was able to install it without command line tools using the Xcode for Mavericks.
-
radtek over 9 yearsThis works great for old xcode in 10.8, did it work for Mavericks?
-
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 over 9 yearsI 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 over 9 yearsPlease add a bit more, and explain why he should do that.
-
Raffi over 9 yearsWorks also for Yosemite OSX 10.10
-
Bugs Bunny over 9 yearsStep 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 over 9 yearsare you installing pil or pillow? PIL is deprecated, I'll update this.
-
Bugs Bunny over 9 yearsDoesn't matter. PIL or Pillow, it might still be useful for some poeple to resolve symlinking freetype/freetype2 issue. But thanks!
-
radtek over 9 yearsYeah I added stuff in step 2 for unlink /link if upgrading. If missing something can you edit and I'll accept?
-
tamasgal over 9 yearsDon't mess around with symlinks, run
xcode-select --install
and you're fine. (as Will mentioned) -
fun_vit over 9 yearssudo pip install pil --allow-external pil --allow-unverified pil helped me in 2015
-
Paul Kenjora over 9 yearsUSE THE UPDATE METHOD: xcode-select --install WORKS!
-
rozochkin about 9 yearsthanks! for 10.10 use: sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 /usr/local/include/X11
-
Big Rich over 8 yearsAlthough
xcode-select --install
is helpful, I still had to symlink X11 issuingln -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 over 8 yearsThis fixes the issue with Mac version 10.11.2 (15C50).
-
Most Wanted about 5 years
ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 /usr/local/include/X11
worked on MacOS Mojave 10.14