Installing PIL to use with Django on Mac OS X

后端 未结 9 940
梦如初夏
梦如初夏 2020-12-13 21:40

I\'m really annoyed by installation of PIL (Python Imaging Library) on Mac OS X 10.6. Does anyone have it installed and could post the recipe here? I\'ve tried a lot of them

9条回答
  •  甜味超标
    2020-12-13 22:06

    I'm using OS X 10.5.8, gcc 4.2.1, python 2.7.5, libjpegv9 and Pillow 2.1.0 (which is based on PIL).

    My problem apparently (but it's just a guess) was caused by architecture incompatibilities of the libjpeg and python (and Pillow) builds.

    Building python and libjpeg from source using only 32bit arch solved it. I installed all the other python libraries, Pillow included, just by using

    pip install xxxxx
    

    and it worked fine.

    Details

    First I tried both a dmg from the python.org site and a universal build installed via macports. I had not specified universal when installing but macports installed both i386 and ppc architectures anyways.

    That caused me problems because libjpeg compiles only to i386 by default.

    To check the build of the binaries, I did:

    file /usr/bin/python
    

    /usr/bin/python: Mach-O universal binary with 2 architectures

    /usr/bin/python: Mach-O executable i386

    /usr/bin/python: Mach-O executable ppc

    file /usr/local/lib/libjpeg.dylib 
    

    /usr/local/lib/libjpeg.dylib: Mach-O dynamically linked shared library i386

    When building PIL (or Pillow), it seemed to use the same build options as python "-gcc i386 -gcc ppc" (which seems logical).

    All went well until it built the "_imaging" module. There, it showed a warning that libjpeg.dylib was not of the right architecture but in the end it showed that JPEG was available just the same.

提交回复
热议问题