How can I install PIL on mac os x 10.7.2 Lion
I've tried googling & looking up some other people's questions. However, I still couldn't find a clear/simple recipe to install PIL (for python 2.6 or 2.7) on mac os x 10.7.2 Lion.
Solution 1:
If you use homebrew, you can install the PIL with just brew install pil
. You may then need to add the install directory ($(brew --prefix)/lib/python2.7/site-packages
) to your PYTHONPATH, or add the location of PIL directory itself in a file called PIL.pth
file in any of your site-packages directories, with the contents:
/usr/local/lib/python2.7/site-packages/PIL
(assuming brew --prefix
is /usr/local
).
Alternatively, you can just download/build/install it from source:
# download
curl -O -L http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz
# extract
tar -xzf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7
# build and install
python setup.py build
sudo python setup.py install
# or install it for just you without requiring admin permissions:
# python setup.py install --user
I ran the above just now (on OSX 10.7.2, with XCode 4.2.1 and System Python 2.7.1) and it built just fine, though there is a possibility that something in my environment is non-default.
Solution 2:
This is something I wrote for the folks at work. It's a full workup for getting a clean OSX Lion working virtualenv using django + git + some other stuff:
https://gist.github.com/1781374
The most important lines for you are:
Install libjpeg (PIL req)
curl -O http://www.ijg.org/files/jpegsrc.v8c.tar.gz
tar -xvzf jpegsrc.v8c.tar.gz
cd jpeg-8c
./configure
make
sudo make install
cd ../
Install freetype (more PIL requirements)
curl -O http://ftp.igh.cnrs.fr/pub/nongnu/freetype/freetype-2.4.5.tar.gz
tar -xvzf freetype-2.4.5.tar.gz
cd freetype-2.4.5
./configure
make
sudo make install
cd ../
Install PIL (usually in the requirements.txt so I don't have it in the above linked instruction)
pip install PIL
or some folks have to (not sure what the configuration difference that causes this is):
sudo pip install PIL
EDIT:
ALSO note that with LION command line tools aren't installed by default, you have to manually enable them, open XCode got to preferences then downloads and select command line tools to be installed before you can compile anything (noted at the top of my GIST)
Solution 3:
One way is via Macports
Install the base macports as per the installation guide
Then install the py27-pil port by port install py27-pil
You will then need to use the python installed by macports by using port select --set python python27
I find it easier to use a package manager like macports (or fink or homebrew) when you require C libraries to be installed as well as python code.
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()
Can't install PIL after Mac OS X 10.9
Solution 5:
u may try this in terminal:
- sudo easy_install pip
- sudo pip install pil