[Django]-Error in PIL installed with PIP – Django,Python

2πŸ‘

βœ…

You get this error if PIL is compiled without jpeg support. I also got this when the destination directory was not writeable.

Once PIL has compiled, if you read

JPEG support not available

the library for handling JPEG files, or part of it, is missing. Fix this just installing the library (in my case it was libjpeg62-dev) and run pip again, maybe inside a virtualenv. If this is not enough, probably your system has some more quirk. Look at this post (ubuntuforums) for the fix.

πŸ‘€Paolo

10πŸ‘

PIL need to find some libraries like libjpeg and libz during installation.

We encountered the same problems on our server and we installed PIL system-wide using

aptitude install python-imaging

This is a quick fix and it works for us.

Also googling about this show two ways how to fix this problem using PIL.

The first one is to symlink libjpeg.so, libfreetype.so and libz.so from /usr/lib/x86_64-linux-gnu/ to /usr/lib

The second one is to use pip --no-install key to download the package and then alter the setup.py to put correct paths there

1. Call 'pip install -I pil --no-install' to download and unpack the PIL source into your build directory;
2. Get into your build directory and edit setup.py;
3. Find the line that says 'add_directory(library_dirs, "/usr/lib")' (line 214 here);
4. Add the line 'add_directory(library_dirs, "/usr/lib/x86_64-linux-gnu/")' afterwards;
5. Call 'pip install -I pil --no-download' to finish the installation.

If you have i386 arch use i386-linux-gnu instead of x86_64-linux-gnu

πŸ‘€Igor

4πŸ‘

if you’re using pip and virtualenv then there’s no need to mess with system paths.

PIL installed via pip has trouble finding the relevant libraries on ubuntu 12.10 (and some earlier) on x86_64

to fix:

# commands for recent debian/ubuntu
sudo apt-get install libjpeg libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev

for i in libjpeg.so libfreetype.so libz.so
    do ln -s /usr/lib/x86_64-linux-gnu/$i $VIRTUAL_ENV/lib/
done
pip uninstall pil
pip install pil
πŸ‘€scytale

1πŸ‘

My fix for this is to make sure you have packages libjpeg-dev and libpng-dev installed before doing the pip install of PIL.

sudo apt-get install libjpeg-dev libpng-dev

will probably do. Then pip gets PIL from source, compiles with jpeg and png support.

πŸ‘€Spacedman

Leave a comment