Tutorial on installing Python's Pillow library on Mac OS, pythonpillow

Source: Internet
Author: User
Tags webp macbook

Tutorial on installing Python's Pillow library on Mac OS, pythonpillow

Today, I made a python tool for my friend and found that the ptyhon support library is missing in the system. The following information is returned:

ImportError: No module named PIL
Then download and install it. Because there is no python management tool pip on the machine, install it together.
1. Install pip

sudo easy_install pip 

You can directly install pil or pillow after pip is installed successfully.


2. Run pip install pil

pip install Pil 
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/macbook/Library/Logs/pip.log 

3. Install pillow.

pip install --use-wheel Pillow 
Downloading/unpacking Pillow  Downloading Pillow-2.4.0.zip (6.5MB): 5.0MB downloaded Cleaning up... 

When I get it back, I find that the download is not complete. This is a slow process, so I gave up.
4. Git

Download source code https://github.com/python-imaging/Pillow through git

git clone https://github.com/python-imaging/Pillow.git 

Then start compilation and Installation

4.1

python setup.py build_ext -i 

After compilation, you will be prompted to run the test example and find JPEG support not available.

-------------------------------------------------------------------- version   Pillow 2.4.0 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 not available *** OPENJPEG (JPEG2000) support not available --- ZLIB (PNG/ZIP) support available *** LIBTIFF support not available --- FREETYPE2 support available *** LITTLECMS2 support not available *** WEBP support not available *** WEBPMUX support not available -------------------------------------------------------------------- To add a missing option, make sure you have the required library, and set the corresponding ROOT variable in the setup.py script.  To check the build, run the selftest.py script. 

4.2 an error is reported when running python selftest. py because JPEG support not available.


1 tests of 57 failed.

So I had to uninstall pillow.

You can run the pip command to uninstall the SDK.

pip uninstall pillow sudo pip uninstall pillow 
Password: Uninstalling Pillow:  /Library/Python/2.7/site-packages/Pillow-2.4.0-py2.7-macosx-10.9-intel.egg  /usr/local/bin/pilconvert.py  /usr/local/bin/pildriver.py  /usr/local/bin/pilfile.py  /usr/local/bin/pilfont.py  /usr/local/bin/pilprint.py Proceed (y/n)? y  
  Successfully uninstalled Pillow 

After successful installation, you must install libjpeg support.

brew install libjpeg 

Recompile pillow after successful installation

-------------------------------------------------------------------- version   Pillow 2.4.0 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 *** OPENJPEG (JPEG2000) support not available --- ZLIB (PNG/ZIP) support available *** LIBTIFF support not available --- FREETYPE2 support available *** LITTLECMS2 support not available *** WEBP support not available *** WEBPMUX support not available -------------------------------------------------------------------- python selftest.py  -------------------------------------------------------------------- Pillow 2.4.0 TEST SUMMARY  -------------------------------------------------------------------- Python modules loaded from /Users/macbook/yyang/app-devel-source/python/Pillow/PIL Binary modules loaded from /Users/macbook/yyang/app-devel-source/python/Pillow/PIL -------------------------------------------------------------------- --- PIL CORE support ok --- TKINTER support ok --- JPEG support ok *** JPEG 2000 support not installed --- ZLIB (PNG/ZIP) support ok *** LIBTIFF support not installed --- FREETYPE2 support ok *** LITTLECMS2 support not installed *** WEBP support not installed -------------------------------------------------------------------- Running selftest: --- 57 tests passed. 

Last install

sudo python setup.py install 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.