PIL /JPEG Library: “decoder jpeg not available”

后端 未结 8 1184
醉酒成梦
醉酒成梦 2021-01-29 23:50

I tried to use PIL to do some JPEG work in my django app with PIL but I\'m getting this IOError.. not sure what to do.

\"\"decoder jpeg not available\"\"
         


        
相关标签:
8条回答
  • 2021-01-29 23:56

    You can build PIL from source: http://effbot.org/zone/pil-decoder-jpeg-not-available.htm

    0 讨论(0)
  • 2021-01-29 23:59

    There is a selftest.py in your Imaging installation folder, try:

    python selftest.py
    

    you will see something like that:

    --------------------------------------------------------------------
    *** PIL CORE support not installed
    *** TKINTER support not installed
    --- JPEG support ok
    --- ZLIB (PNG/ZIP) support ok
    *** FREETYPE2 support not installed
    *** LITTLECMS support not installed
    --------------------------------------------------------------------
    

    if JPEG support not available, Centos:

    yum install libjpeg-devel
    yum install freetype-devel 
    yum install libpng-devel
    
    0 讨论(0)
  • 2021-01-30 00:02

    I have found this answer from author "edward"

    On Ubuntu precise, PIL doesn't find the jpeg library files, even once they are installed. The easiest way to fix this is to make a symlink after you have installed the jpeg dev package. So, I needed an extra step:

    for x64 OS

    pip uninstall PIL
    sudo apt-get install libjpeg8-dev
    sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
    pip install PIL
    

    for x32 OS

    pip uninstall PIL
    sudo apt-get install libjpeg8-dev
    sudo ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib
    pip install PIL
    

    I confirm that this is working for me on Ubuntu Linux 12.04.


    If you are a Mac user - you need to install Xcode and Command Line Tools. Read how to do this

    0 讨论(0)
  • 2021-01-30 00:04

    On Debian distributions use libjpeg62-turbo-dev instead of libjpeg8-dev

    0 讨论(0)
  • 2021-01-30 00:06

    A stronger answer can be found at install pil on virtualenv with libjpeg

    For me what finally worked on Ubutu was:

    pip uninstall PIL
    sudo apt-get install libjpeg8-dev
    pip install PIL
    

    The Python Imaging Library (PIL) seems really picky about version and location of the jpeg libraries. And because PIL is written in C and compiled, you need the development versions of the library in addition to the runtime versions.

    0 讨论(0)
  • 2021-01-30 00:11

    For mac's users, You can download the library from here: http://ethan.tira-thompson.com/Mac_OS_X_Ports.html. Then, uninstall and install PIL

    0 讨论(0)
提交回复
热议问题