How to install PIL with pip on Mac OS?
To bask in the glory of Pillow, a more maintained fork of PIL, on your Mac OS, execute this on your terminal:
Permission issues? Run like Forrest (sudo
) or better yet, enjoy a mess-free virtual environment.
Prepare your installation batter
Before cracking eggs, we arrange all the ingredients, don't we? Thus, before installing Pillow, let's make sure you've got Xcode and Xcode Command Line Tools. They ensure a smooth sail and keep the monstrous 'clang' errors at bay.
Here's the magic spell:
- Download and install Xcode from the Mac App Store. Be careful, it's a large download!
- Once you've slayed the Xcode beast, get the Xcode Command Line Tools by muttering these words in your Terminal:
- Update pip to the latest version for maximal effectiveness. Pip also needs to stay in shape!
- Optionally, installing libraries such as python-dev, libjpeg-dev, libpng-dev, and libfreetype6-dev with brew can be a good idea, especially if you're looking to do more with image manipulation:
Undo potential jinxes
Troubles on your way? Here's your patronus charm:
- Add the
--verbose
flag to check progress, like watching your own DIY video. - Symbolic links for libfreetype.so, libjpeg.so, and libz.so might be needed if the terminal screams about missing these files.
- To install a particular version of Pillow, specify the version in the command, like ordering your favorite coffee:
- Beware of security warnings. In the world of Internet, it's always Halloween.
Juggling dependencies and permissions
Getting Pillow to play nicely with your Mac involves understanding dependencies and system permissions. It's a bit like a reality show, let the games begin:
- Dependencies like libjpeg and libpng might require special installation procedures. Brew is your friend here:
- If you run into a brick wall of permission issues, break it down with
sudo
or opt for a comfortable virtual environment. It's less messy!
Cross platform but not cross complications
A Mac isn't just any machine. There might still be a hoop or two to jump through:
- If you're on the Python 3 track, use the following spell:
- To make sure all your efforts were worthwhile, summon Python to check the installation:
- For those unfortunate times when
pip
gives up, easy_install steps up to the plate: - Code refactor? Simply move from PIL to 'from PIL import Image' when switching on to Pillow.
Navigating the Pillow kingdom
Get the most from your Pillow kingdom. Explore every nook and cranny:
- Use Pillow's native operations to perform image resizing, filtering and more. Fast and furious!
- Marvel at Pillow’s ImageEnhance module to quickly enhance image quality.
- Work with Pillow in Python’s virtual environments for dependency joyrides.
Was this article helpful?