Python PIL cannot locate my “libjpeg”

前端 未结 5 1536
长发绾君心
长发绾君心 2021-02-05 21:51

I cannot use PIL because it cannot find my libjpeg!

First, I installed PIL default. And when I ran the selftest.py, it gave me:

IOError: dec         


        
相关标签:
5条回答
  • 2021-02-05 22:25

    I had the same issue. In my case, I need to set:

    JPEG_ROOT="/usr/lib64/"
    

    instead of:

    JPEG_ROOT="/usr/lib/"
    

    Good luck.

    0 讨论(0)
  • 2021-02-05 22:35

    You could also try to use Pillow instead of PIL.

    Pillow is a PIL fork to "foster active development of PIL". In versions 1.7.0 and 1.7.1 they made some changes to support multi-arch (see the changelog).

    0 讨论(0)
  • 2021-02-05 22:39

    There at least 3 header sets that you will want to install. 1 more if you want to deal with Tiff's

    freetype, libjpeg, zlib all of which will be in the following packages on CentOS:

    == 32 Bit: zlib-devel.i386 libjpeg-devel.i386 freetype-devel.i386

    == 64 Bit: zlib-devel.x86_64 libjpeg-devel.x86_64 freetype-devel.x86_64

    As you did before you will want to edit the following variables in the setup.py file:

    FREETYPE_ROOT JPEG_ROOT ZLIB_ROOT

    Setting there values to /usr/lib or /usr/lib64 based on your platform. Once done you will most likely want to run

    python setup.py build --force
    python setup.py install
    

    That will force rebuild all your lib for PIL and reinstall them raw.

    0 讨论(0)
  • 2021-02-05 22:40

    You need the libjpeg headers as well, not only the library itself. Those packages are typically called something ending in headers or dev, depending on what distribution you have.

    0 讨论(0)
  • 2021-02-05 22:45

    Today I was facing the same problem, and I've found the solution. Basically it involves remove the PIL, install lipjpeg through Fink and re-install the PIL.

    I wrote an article telling step by step how to do that. If interesting check this out.

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