5

I am trying to install PIL on Mac OSX 10.7.4 but after several hours attempt couldn't succeed. All the time I have encountered the same problem provided detail in pastebin link below. Enlighten me!!

Setting

tbc:~ mystic$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

Pastebin

I searched and tried from several sources:

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Image
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named Image
>>> import PIL
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named PIL
>>>

Edited as suggested by jdi but still running through the same problem as shown in above pastebin link

tbc:jpeg-8c mystic$ xcode-select -version
xcode-select version 2003.
tbc:jpeg-8c mystic$ which xcode-select
/usr/bin/xcode-select
tbc:jpeg-8c mystic$ xcode-select -print-path
/Applications/Xcode.app/Contents/Developer
tbc:jpeg-8c mystic$

Further, I gave try with homebrew as suggested by the "the paul"

tbc:cellar mystic$ brew link jpeg
Linking /usr/local/Cellar/jpeg/8d... 3 symlinks created
tbc:cellar mystic$ brew install pil
Error: pil-1.1.7 already installed
tbc:cellar mystic$ brew uninstall pil
Uninstalling /usr/local/Cellar/pil/1.1.7...
tbc:cellar mystic$ brew install pil
==> Downloading http://effbot.org/downloads/Imaging-1.1.7.tar.gz
Already downloaded: /Library/Caches/Homebrew/pil-1.1.7.tar.gz
==> python setup.py build_ext
==> python setup.py install --prefix=/usr/local/Cellar/pil/1.1.7
==> Caveats
This formula installs PIL against whatever Python is first in your path.
This Python needs to have either setuptools or distribute installed or
the build will fail.
Warning: Non-executables were installed to "bin".
Installing non-executables to "bin" is bad practice.
The offending files are:
/usr/local/Cellar/pil/1.1.7/bin/pilfont.py
==> Summary
/usr/local/Cellar/pil/1.1.7: 174 files, 2.0M, built in 15 seconds
tbc:cellar mystic$ python 
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pil
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pil
>>> from PIL import Image
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named PIL

Here is the log of .pip

Its complaining about

/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory

but stdarg.h file is there at the same location.

I am not understanding why its trying to locate in MacOSX10.6.sdk as my current version of Lion isMacOSX10.7.sdk

Getting crazy!!!

Community
  • 1
  • 1
thchand
  • 358
  • 2
  • 8
  • 20
  • That looks like it worked. Try opening a fresh python console and typing `import Image`. If it didn't give an error you are good to go. – Nick Craig-Wood May 18 '12 at 17:56
  • I have updated question and provided details in pastebin link – thchand May 18 '12 at 17:58
  • It looks like there's a problem with `/Developer/SDKs/MacOSX10.6.sdk`. Do you have it on your hard drive? – chl May 18 '12 at 18:36
  • Does this exist for you? ` /Developer/SDKs/MacOSX10.6.sdk`. In lion with the latest XCODE they moved the SDK location – jdi May 18 '12 at 19:57
  • Yes, I have MacOSX10.6.sdk and MacOSX10.7.sdk both inside Developer folder – thchand May 18 '12 at 20:10

3 Answers3

9

If you are on Lion, using the newest XCode, then a potential problem for you is that they moved the location of the developer SDKs. Packages that expected them to live in /Developer/ would no longer find them as needed.

Reference this article about specifics:
http://www.agile-workers.com/web/2012/03/qt-qmake-osx_sdk-xcode/

But in summary, what you might need to do is run:
sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer
to point at the new location.

A manual fix might be to just symlink the SDK from /Applications/Xcode.app/Contents/Developer/... => /Developer/..., but I would first try the xcode-select tool.

Update: Some more suggestions based on your new updates

First off, I can't tell from what you posted whether PIL failed to build because of the SDK or not. If it built successfully, and you are using the standard apple python, then chances are the homebrew python path is not in your own python path.

$ python
>>> import sys
>>> sys.path.append("/usr/local/lib/python2.7/site-packages")
>>> from PIL import Image

If that still errors, then I suppose the issue is still related to missing SDK location. You could symlink the new location of the SDK to the old one with:

mkdir -p -v /Developer/SDKs
ln -s /Applications/Xcode.app/Contents/Developer/MacOSX10.6.sdk  /Developer/SDKs/MacOSX10.6.sdk

Or, you can try explicitly setting the the sdk path when you build pil:

brew remove pil
export SDKROOT=/Applications/Xcode.app/Contents/Developer/MacOSX10.6.sdk
brew install pil
jdi
  • 90,542
  • 19
  • 167
  • 203
  • His MacOSX10.7.sdk *is* under /Developer, so possibly he hasn't updated xcode. – the paul May 18 '12 at 20:31
  • @thchand: If thats the case, then you now have old SDK's because they should exist now at the new xcode location. You should be able to use the xcode-select tool to point them at the right place. – jdi May 18 '12 at 21:33
  • I have edited question according to your suggestion but still the same problem – thchand May 19 '12 at 07:11
  • I think i followed wrong suggestion from someone blog and deleted gcc-4.2 from /usr/bin. Getting error "unable to execute gcc-4.2: No such file or directory". Again tried to install by >>> brew install https://raw.github.com/gist/1587643/gcc42.rb. Didn't work out – thchand May 19 '12 at 18:41
  • @thchand: check out my answer from this pretty similar question about installing options: http://stackoverflow.com/questions/10658909/unable-to-install-with-easy-install-or-pip-on-mac/10659066 – jdi May 19 '12 at 18:50
  • @jdi - You are the man, it worked as per your suggestion. Took my three days in figuring out the problem. – thchand May 20 '12 at 21:29
  • @thchand: Awesome. I knew something out of all this info would end up being useful :-) , I am sure thepaul also worked hard to help you via conversation. – jdi May 20 '12 at 21:34
  • I have been unsuccessful at trying to get `sys.path.append("/usr/local/lib/python2.7/site-packages")` in the default path. Is there any way? – Dex Jul 01 '12 at 09:39
  • @Dex: Did you add it to your PYTHONPATH env variable in your `~/.profile` (or `~/.bash_profile` if that exists already)? – jdi Jul 01 '12 at 15:49
  • I tried setting PYTHONPATH manually in the shell before running my python script and it didn't seem to do anything. – Dex Jul 02 '12 at 03:40
1

Easy solution:

  1. install Homebrew
  2. brew install pillow

:)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
the paul
  • 8,972
  • 1
  • 36
  • 53
0

If you have Homebrew installed, this will do the the job:

brew install pillow
Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Sebyddd
  • 4,305
  • 2
  • 39
  • 43