5

I am having some trouble getting Django & PIL work properly since upgrading to Snow Leopard.

I have installed freetype, libjpeg and then PIL, which tells me:

--- TKINTER support ok
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok

but when I try to upload a jpeg through the django admin interface I get:

Upload a valid image. The file you uploaded was either not an image or a corrupted image.

It works fine with PNG files.

Any Ideas?

Cato Johnston
  • 44,131
  • 10
  • 39
  • 42
  • 1
    This worked for me too. I run Leopard (10.5.8). I previously reinstalled jpeg with MacPorts (using sudo port install jpeg), don't know if that made a difference. – Hannes Jan 13 '10 at 11:32

3 Answers3

14

Cato

I had the same experience with Leopard 10.5.x Here is what I did to fix it, (may not work for you).

  1. Go to your PIL working folder (where you unzipped PIL) cd to your build folder cd to your lib.macosx-10.* folder (specific to your os) remove *.so cd back to your PIL build folder (I logged in as su for this, but you can sudo these if you like)
  2. python setup.py clean
  3. python setup.py build
  4. python setup.py install

This rebuilds PIL clean. The reason your jpeg reports ok, is that it just looks for the existence of the jpeg lib files, but not the dependency that happens from a clean build and install of PIL.

Hope this solves your problem, mine was more likely related to the order of installation but maybe it will help...

  • Ken
Ken Gendrich
  • 156
  • 1
  • 2
5

As a follow up to Ken's response, I had the same problem with Snow Leopard 10.6.x which was caused by installing PIL before libjpeg. After installing libjpeg, I reinstalled PIL by doing the following.

  1. cd to PIL working folder
  2. python setup.py clean
  3. python setup.py build_ext -i <-- This rebuilds PIL
  4. python selftest.py - Run the selftest to confirm PIL is installed ok
  5. python setup.py install
Jared Knipp
  • 5,880
  • 7
  • 44
  • 52
3

I ran into a similar issue while on Ubuntu 8.04. I was able to get myself out of it by simply re-issuing my PIL install (via pip):

pip install PIL --upgrade

Not sure what the issue was but I suspect it's similar to what others here reported.

Ben Keating
  • 8,206
  • 9
  • 37
  • 37
  • `pip install -U PIL Pillow` did it for me, thanks. Be sure to run `sudo apt-get install libjpeg62 libjpeg8 libjpeg8-dev` first. – elimisteve Mar 05 '13 at 09:29