views:

640

answers:

1

Hello there. I'm using Buildout for my Django projects, with FeinCMS. I've got it setup great locally on my Mac OSX Snow Leopard, with no errors coming up at all when I use runserver. But when I upload an image with FeinCMS in the admin area it comes up with a "Exception Value: The _imaging C module is not installed" error.

My traceback is here: http://dpaste.com/149492/

My buildout.cfg file looks like this:

   [buildout]
   parts =
        zlib
        libjpeg
        PILwoTk
        django-mptt
        django-staticfiles
        django

    eggs =
        PILwoTk
        feincms

    [zlib]
    recipe = hexagonit.recipe.cmmi
    url = http://www.zlib.net/zlib-1.2.3.tar.gz
    configure-options = --shared

    [libjpeg]
    recipe = hexagonit.recipe.cmmi
    url = http://www.ijg.org/files/jpegsrc.v8.tar.gz

    [PILwoTk]
    recipe = zc.recipe.egg:custom
    find-links = http://download.zope.org/distribution/
    include-dirs =
        ${zlib:location}/include
        ${libjpeg:location}/include
    library-dirs =
        ${zlib:location}/lib
        ${libjpeg:location}/lib
    rpath =
        ${zlib:location}/lib
        ${libjpeg:location}/lib

    [django-mptt]
    recipe = infrae.subversion
    urls = http://django-mptt.googlecode.com/svn/trunk/mptt mptt

    [django-staticfiles]
    recipe = mercurialrecipe
    repository = http://bitbucket.org/jezdez/django-staticfiles/

    [django]
    recipe = djangorecipe
    version = 1.1.1
    project = recoilmedia
    eggs = ${buildout:eggs}
    extra-paths =
        ${django-mptt:location}
        ${django-staticfiles:location}

I've asked on FeinCMS group, on Django IRC/group but with absolutely no help from anyone on what this can be. I've searched all over the net for solutions and still haven't found one that works. It's diving me up the wall, I've been stuck on it all day. Does anyone possibly know what the problem is?

+1  A: 

I have gone through the same thing today and found a solution. The problem is that PIL will look for 32-bit libjpeg and Snow Leopard will compile the library as x86_64 by default. This could be fixed by modifying your libjpeg section to look like this:

[libjpeg]
recipe = hexagonit.recipe.cmmi
url = http://www.ijg.org/files/jpegsrc.v8.tar.gz
environment =
  CC=gcc -arch i386

You can check which library _imaging.so is using by running:

otool -L path/to/PIL/_imaging.so

It should output the line pointing to libjpeg.8.dylib in your buildout directory.

Edit: On a second thought, running buildout with CC="gcc -arch i386" bin/buildout will also works. If you want to compile a fat binary, remember to use GCC-4.0 and add CPP: CC="gcc-4.0 -arch i386 -arch ppc" CPP="gcc-4.0 -E" bin/buildout.

That's exactly it. The FeinCMS media library makes it a bit more visible when PIL isn't installed because it tries to determine the media file type on upload and looks into the file when the extension says it is an image.
Matthias Kestenholz