Install PIL on Mac OS

After installing PIL, when processing jpg, it prompts "decoder jpeg not available". It turns out that PIL installation does not provide support for jpeg.

First uninstall the installed PIL:

On Mac, you can find site-packages as follows:

[python]  view plain   copy
  1. import django  
  2. dir(django)  
  3. print django.__path__  

After searching, mine is under /Library/Python/2.7/site-packages.

Enter the directory, delete the PIL directory and PIL.pth, and the installed PIL will be uninstalled.

Download libjpeg and zlib:

http://www.ijg.org/files/jpegsrc.v7.tar.gz

http://zlib.net/zlib-1.2.7.tar.gz

Install libjpeg:

[python]  view plain   copy
  1. $ tar zxvf jpegsrc.v7.tar.gz   
  2. $ cd jpeg-7  
  3. $ ./configure --enable-shared --enable-static  
  4. $ make  
  5. $ sudo make install  

By default, it is installed under: /usr/local/lib.

Install zlib:

[plain]  view plain   copy
  1. $ tar zxvf zlib-1.2.7.tar.gz  
  2. $ ./configure  
  3. $ make  
  4. $ sudo make install  

By default, it is installed under: /usr/local/lib.

Modify the setup.py of PIL:

[python]  view plain   copy
  1. JPEG_ROOT = "/usr/local/include"  
  2. ZLIB_ROOT = "/usr/local/include"  

Compile PIL:

[python]  view plain   copy
  1. $ python setup.py build_ext -i  


test:

[python]  view plain   copy
  1. $ python selftest.py  

If prompted:

[plain]  view plain   copy
  1. "57 tests passed."  


Then install:

[plain]  view plain   copy
  1. $ python setup.py install  

Installed.



zz http://blog.csdn.net/liushuaikobe/article/details/8729652

Guess you like

Origin blog.csdn.net/args_/article/details/52669836