Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pillow installed with jpeg still says "IOError: decoder jpeg not available" #1338

Closed
certik opened this issue Jul 6, 2015 · 2 comments
Closed

Comments

@certik
Copy link

certik commented Jul 6, 2015

Here is how it is triggered:

In [3]: from PIL import Image

In [5]: a = Image.open("images/spice_1.jpg")

In [7]: from io import BytesIO

In [9]: b = BytesIO()

In [10]: a.save(b, "PNG")
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-10-7850474bd2ff> in <module>()
----> 1 a.save(b, "PNG")

/home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/Image.pyc in save(self, fp, format, **params)
   1669 
   1670         # may mutate self!
-> 1671         self.load()
   1672 
   1673         save_all = False

/home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/ImageFile.pyc in load(self)
    201 
    202             for d, e, o, a in self.tile:
--> 203                 d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
    204                 seek(o)
    205                 try:

/home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/Image.pyc in _getdecoder(mode, decoder_name, args, extra)
    418         return decoder(mode, *args + extra)
    419     except AttributeError:
--> 420         raise IOError("decoder %s not available" % decoder_name)
    421 
    422 

IOError: decoder jpeg not available

But pillow has been installed with jpeg support, as part of Hashdist, here is the PR hashdist/hashstack#806, here is the build script:

$ hit show d2.yaml script pillow
set -e
export HDIST_IN_BUILD=yes
export MAX_CONCURRENCY=1
export SETUPTOOLS_PACKAGE_EXTRA_OPTIONS="build_ext --enable-zlib --enable-freetype --enable-jpeg2000 --include-dirs=${ZLIB_DIR}/include:${PNG_DIR}/include:${FREETYPE_DIR}/include:${OPENJPEG_DIR}/include --library-dirs=${ZLIB_DIR}/lib:${PNG_DIR}/lib:${FREETYPE_DIR}/lib:${OPENJPEG_DIR}/lib"
export CPPFLAGS="-I${FREETYPE_DIR}/include -I${OPENJPEG_DIR}/include -I${PATCHELF_DIR}/include -I${PNG_DIR}/include -I${PYTHON_DIR}/include -I${SETUPTOOLS_DIR}/include -I${ZLIB_DIR}/include"
export LDFLAGS="-L${FREETYPE_DIR}/lib -Wl,-rpath=${FREETYPE_DIR}/lib -L${OPENJPEG_DIR}/lib -Wl,-rpath=${OPENJPEG_DIR}/lib -L${PATCHELF_DIR}/lib -Wl,-rpath=${PATCHELF_DIR}/lib -L${PNG_DIR}/lib -Wl,-rpath=${PNG_DIR}/lib -L${PYTHON_DIR}/lib -Wl,-rpath=${PYTHON_DIR}/lib -L${SETUPTOOLS_DIR}/lib -Wl,-rpath=${SETUPTOOLS_DIR}/lib -L${ZLIB_DIR}/lib -Wl,-rpath=${ZLIB_DIR}/lib"

export PYTHONPATH=${ARTIFACT}/lib/python2.7/site-packages:$PYTHONPATH
mkdir -p ${ARTIFACT}/lib/python2.7/site-packages
${PYTHON} -c 'import setuptools; __file__="setup.py"; exec(open(__file__).read())' \
   ${SETUPTOOLS_PACKAGE_EXTRA_OPTIONS} \
   install \
   --prefix=. --root=${ARTIFACT} \
   --single-version-externally-managed
rm -rf ${ARTIFACT}/lib/python2.7/site-packages/*.pth

You can see that the libraries are linked with jpeg support:

$ ldd /home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/*.so
/home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/_imagingft.so:
    linux-vdso.so.1 =>  (0x00007ffe11377000)
    libfreetype.so.6 => /home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/../../../../../../freetype/yyxa7627ngek/lib/libfreetype.so.6 (0x00007f946f06c000)
    libpython2.7.so.1.0 => /home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/../../../../../../python/7h32ksdqcejo/lib/libpython2.7.so.1.0 (0x00007f946ec63000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f946ea21000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f946e65c000)
    libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f946e435000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f946e230000)
    libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f946e02d000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f946dd26000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f946f50f000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f946db0d000)
/home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/_imagingmath.so:
    linux-vdso.so.1 =>  (0x00007fff49396000)
    libpython2.7.so.1.0 => /home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/../../../../../../python/7h32ksdqcejo/lib/libpython2.7.so.1.0 (0x00007f8e24adb000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f8e24898000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8e244d3000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8e242ce000)
    libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f8e240ca000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8e23dc4000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f8e250ec000)
/home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/_imagingmorph.so:
    linux-vdso.so.1 =>  (0x00007fffcb7e1000)
    libpython2.7.so.1.0 => /home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/../../../../../../python/7h32ksdqcejo/lib/libpython2.7.so.1.0 (0x00007f5d7bbfe000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5d7b9bb000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5d7b5f6000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5d7b3f1000)
    libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f5d7b1ed000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5d7aee7000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f5d7c20c000)
/home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/_imaging.so:
    linux-vdso.so.1 =>  (0x00007ffca87f3000)
    libopenjp2.so.7 => /home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/../../../../../../openjpeg/6azwtldpgrmo/lib/libopenjp2.so.7 (0x00007f4f844ad000)
    libz.so.1 => /home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/../../../../../../zlib/v6anirfvk2op/lib/libz.so.1 (0x00007f4f84292000)
    libpython2.7.so.1.0 => /home/ondrej/.hashdist/bld/profile/qiuivcebvrmc/lib/python2.7/site-packages/PIL/../../../../../../python/7h32ksdqcejo/lib/libpython2.7.so.1.0 (0x00007f4f83e8a000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f4f83c48000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4f83882000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4f8357c000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4f83376000)
    libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f4f83173000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f4f84958000)

Here is the full build log: https://gist.github.com/certik/785890e6e72e2ac51669. The relevant part is perhaps:

2015/07/06 10:53:58 - INFO: [package:run_job] PIL SETUP SUMMARY
2015/07/06 10:53:58 - INFO: [package:run_job] --------------------------------------------------------------------
2015/07/06 10:53:58 - INFO: [package:run_job] version      Pillow 2.9.0
2015/07/06 10:53:58 - INFO: [package:run_job] platform     linux2 2.7.9 (default, May 16 2015, 09:32:20)
2015/07/06 10:53:58 - INFO: [package:run_job]              [GCC 4.8.2]
2015/07/06 10:53:58 - INFO: [package:run_job] --------------------------------------------------------------------
2015/07/06 10:53:58 - INFO: [package:run_job] *** TKINTER support not available
2015/07/06 10:53:58 - INFO: [package:run_job] *** JPEG support not available
2015/07/06 10:53:58 - INFO: [package:run_job] --- OPENJPEG (JPEG2000) support available (2.1)
2015/07/06 10:53:58 - INFO: [package:run_job] --- ZLIB (PNG/ZIP) support available
2015/07/06 10:53:58 - INFO: [package:run_job] *** LIBTIFF support not available
2015/07/06 10:53:58 - INFO: [package:run_job] --- FREETYPE2 support available
2015/07/06 10:53:58 - INFO: [package:run_job] *** LITTLECMS2 support not available
2015/07/06 10:53:58 - INFO: [package:run_job] *** WEBP support not available
2015/07/06 10:53:58 - INFO: [package:run_job] *** WEBPMUX support not available

So OPENJPEG is there. JPEG is not --- what does that mean? I thought OPENJPEG gives the JPEG support. Maybe that's the problem?

@wiredfool
Copy link
Member

Openjpeg is for JPEG2000 support, not plain old JPEG support. You nee libjpeg (of one form or another, plain, turbo, or other api compatible) + the headers, either as a -dev package or whatever your distro uses.

@certik
Copy link
Author

certik commented Jul 6, 2015

Ah, I didn't know. Thanks! I am closing this, I'll reopen if it still doesn't work with jpeg.

@certik certik closed this as completed Jul 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants