[Django]-(Django and PIL) encoder error -2 when writing image file

0👍

Got the same error when using it with sorl-thumbnail. After long time spend on Google, i have came with this simple solution. Actually the error comes from PIL(python-pil). But for Ubuntu users, “pip install PIL” is no longer in service :(. But the coolest thing is we can get rid of this error by simple package python-imaging.

sudo apt-get install python-imaging

hopes that you already installed python-pil and other dependencies mentioned in the sorl-thumbnail tutorial,

for sorl-thumbnail

sudo apt-get install libjpeg62 libjpeg62-dev zlib1g-dev

for python-pil

sudo apt-get install python-pil python-pil-doc python-pil-dbg

0👍

Please check my answer here https://stackoverflow.com/a/41018959/1176671
I do it in my Django project, so hope it would help you with Django as well.

Leave a comment