How to install PIL in system library using homebrew?
Asked Answered
B

5

12

In a new SnowLeopard install, I'd like to use homebrew to install PIL. However the recipe installs PIL under cellar instead of in /Library/Python/2.6/site-packages. Is there a way to change the install directory?

Banns answered 5/4, 2011 at 3:26 Comment(0)
B
12

Since there seems to be no "accepted" way of installing homebrew eggs into the system site-packages, here is what I ended up doing:

% brew install pil
% easy_install pip
% pip install pil

The homebrew install grabs and installs all of PIL's dependencies (especially jpeg). The later easy_install then uses them when compiling PIL for the system site-packages. Freetype support doesn't show up in the "easy-installed" version, but that's fine for my purposes.

As my initial goal was to provide a simple way for a web designer to build a django development environment, having an unused homebrew PIL installed is not really a problem.

Hope this helps someone. Still hoping there's a better answer out there.

Banns answered 7/4, 2011 at 3:50 Comment(0)
H
34

Instead of installing pip and another PIL, you can just make a symlink

brew install pil
ln -s /usr/local/Cellar/pil/1.1.7/lib/python2.7/site-packages/PIL /Library/Python/2.7/site-packages/PIL

Tested on Lion, on Snow Leopard, you may need to change paths to use /python2.6 /Python/2.6.

Hairless answered 17/10, 2011 at 11:0 Comment(5)
This is the best solution IMO. It's clean and simple. Homebrew installs its stuff in /usr/local/bin and trying to wrangle it out of there is really catastrophic (and a real pain). Better to symlink the PIL package to where most things OS X looks for it (under /Library/Python/{version} than bust up homebrew for one simple egg.Siberson
I followed your steps but still couldn't import PILVerdi
This doesn't work for me on Mountain Lion. import Image still fails after creating the symlink. Aren't we supposed to add the path to a .pth file somewhere?Epilate
@yorch Yes, it had been working from the start. The proper import is from PIL import Image, not import Image.Epilate
On 10.8 I already had a /Library/Python/2.7/site-packages/PIL so ln failed silently. I had to move it away sudo mv /Library/Python/2.7/site-packages/PIL{,-original} and run ln again, now it works fine ! =D Thank @Hairless !Outbound
A
16

It seems that Pillow replaced PIL in homebrew. The new command is:

brew install Homebrew/python/pillow
Abagael answered 19/4, 2014 at 19:59 Comment(0)
B
12

Since there seems to be no "accepted" way of installing homebrew eggs into the system site-packages, here is what I ended up doing:

% brew install pil
% easy_install pip
% pip install pil

The homebrew install grabs and installs all of PIL's dependencies (especially jpeg). The later easy_install then uses them when compiling PIL for the system site-packages. Freetype support doesn't show up in the "easy-installed" version, but that's fine for my purposes.

As my initial goal was to provide a simple way for a web designer to build a django development environment, having an unused homebrew PIL installed is not really a problem.

Hope this helps someone. Still hoping there's a better answer out there.

Banns answered 7/4, 2011 at 3:50 Comment(0)
A
1

As @BarnabasSzabolcs mentioned, newer versions named pillow. an alternative to brew install Homebrew/python/pillow is pip install pillow. You may need to add sudo, depends on your python environment permissions.

Amargo answered 26/4, 2016 at 13:45 Comment(0)
P
0

For everyone reading this now, today this can be achieved with brew install pillow.

Pertinent answered 20/8 at 22:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.