[Django]-Sorl thumbnail + django issues in production

1👍

Tried everything. Ended up solving itself with a newer Linux distro. Wouldn’t work on Ubuntu 10.04 but after that it works fine for me, 11.04, 11.10, etc.

4👍

A solutions for lazy people like me is to try another THUMBNAIL_ENGINE in the settings file.

I was facing the same problem. As it obviously results from problems with the image library, for my case I’ve decided to simply use a different image library – and it worked. Currently there are 3 possible image libraries: PIL (default), Pgmagick, and ImageMagick/GraphicsMagick. Details are explained here.

Of course, one of the alternative libraries must be installed on the server. Otherwiese, this solution won’t work.

2👍

Have you done your syncdb?

Run this to check : python manage.py thumbnail cleanup

👤thunga

2👍

Short answer: uninstall all versions of ligjpeg dev files except 6.2. Uninstall all versions of PIL. Install an recent sorl.thumbnail and PIL-1.1.7 into a virtualenv using pip so that PIL compiles against libjpeg6.2.

Detailed answer:

I had a lot of trouble with this on a site I mantain – turns it was due to version conflicts between PIL, libjpeg and sorl – someone had installed lots of versions of all of them. I had to strip it down to a single install of PIL1.1.7, libjpeg6.2 and sorl.thumbnail 11.9

Here’s what I had to do (this assumes you’re using virtualenv. If you’re not, well now’s a good time to start):

yum erase python-imaging

oh wait, it was also installed via easy_install so I also have to remove PIL from site-packages:

easy_install -mxN PIL
rm -rf  /usr/lib/python2.6/site-packages/PIL /usr/lib/python2.6/site-packages/PIL.pth

Now I uninstall PIL from my virtualenv

pip uninstall PIL

there seems to be a bug in the version of pip i’m using – I have to remove stuff in the virtualenv build dir or pip won’t install a later version

rm -rf /path/to/virtualenv/build/PIL/

now I have to remove the versions of libjpeg that I don’t want… You should probably do

apt-get remove libjpeg8 libjpeg8-dev

… or whatever incantation is necessary. Of course if you have other stuff that depends on that version of libjpeg then you’re in an interesting situation. I’m sure you can get PIL to install and build against a specific version of libjpeg. Then maybe you can get libjpeg8 to work ok with this – please reply if you do.

On my trainwreck of a server both libjpeg7 and libjpeg8 dev files had been installed from source (in addition to the package manager installed version 6.2 – hilarious eh?) so I had to download the source for both libjpeg7 and libjpeg8, run ./configure and then ./make uninstall. There were still some libs left in /usr/local/lib/ so I had to do rm /usr/local/lib/libjpeg*.

I should have probably just done that last bit but wanted to be thorough.

Check that there are no other installs or remnants of installs of PIL or libjpeg on your system.

Now you can start afresh…

yum install libjpeg-devel 

On this battered old CentOS box that gets version 6.2 which seems to work best with PIL1.1.7. On recent Debian/Ubuntu you’d have to run

apt-get install libjpeg62-dev

now in my virtualenv run

pip install PIL sorl-thumbnail

restart webserver. happiness.

Leave a comment