[Django]-Getting error while running django-cms demo page

20👍

Add JPEG support to Pillow, in Ubuntu you can do the following:

sudo apt-get install libjpeg-dev libfreetype6-dev zlib1g-dev

# Link the libraries for Pillow to find them:

sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/

# reinstall Pillow (In case you have Pillow already installed)
pip install --upgrade --force-reinstall pillow

2👍

Install the required libs:

http://pillow.readthedocs.org/en/latest/installation.html#linux-installation

Then uninstall and reinstall Pillow in your virtualenv

pip uninstall Pillow
pip install --no-cache-dir Pillow

2👍

I actually found the chosen solution here to be great help. I also found that the djangcms installer wants a specific version of Pillow, which results in it not picking up the JPEG module for whatever reason. At the time of this writing, it wanted Pillow==2.8.0 but the latest version that pip --upgrade was installing was 2.9.x. I ran pip install --no-cache-dir --upgrade --force-reinstall pillow==2.8.0 and that seemed to satisfy the djangocms installer’s requirement such that it would retain JPEG compatibility.

You can verify that JPEG support is installed by opening a python shell in the virtualenv.

from PIL import Image

i = Image.open('/path/to/a.jpg')
i.load()

You’ll either get a handle to the loaded image or an exception if there’s no JPEG support.

So pip was succesfully installing a Pillow package with JPEG support, but as soon as I ran the djangocms installer, it was replacing it with a Pillow package without JPEG support. You need to match the version of Pillow that djangocms installer wants. I don’t know where that config is, but you can figure it out with pip freeze or pip list after a failed install.

Hopefully this helps someone.

👤Eric

1👍

I faced the same issue under my BitNami LAMP Virtual Machine and can not solved it from linking the missing files for Pillow. Finally, I solved it:

first, find the lib

(venv)...$ find 2>/dev/null / -name libz.so
/opt/bitnami/common/lib/libz.so

now add the lib directory into pip

(venv)...$ pip install --global-option=build_ext --global-option="-L/opt/bitnami/common/lib" --global-option="-I/opt/bitnami/common/include" --upgrade --force-reinstall pillow

it works:

--------------------------------------------------------------------
PIL SETUP SUMMARY
--------------------------------------------------------------------
version      Pillow 2.7.0
platform     linux2 2.7.6 (default, Mar 22 2014, 22:59:56)
             [GCC 4.8.2]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
--- LIBTIFF support available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available
--------------------------------------------------------------------

also see python pip specify a library directory and an include directory

Leave a comment