IOError: jpeg decoder not available when using pillow

Before someone says "sudo apt-get install libjpeg-dev" or something like that, I don't have sudo access. I am on a server slice that DOES NOT allow me access to sudo. Therefore, I have to do all this in my local directory. This is the only way to do this.

I need a python script to resize an image. It works fine for png files, but it falls apart on jpeg files with the error indicated in the header.

Here are the steps I have taken so far:

  • We downloaded libjpeg-dev and installed it in $HOME/jpegtest , so inside jpegtest / folder is lib /, include / etc.
  • I downloaded Pillow manually and extracted it on $HOME/Pillow
  • I edited setup.py fild to JPEG_ROOT on libinclude(<absolute path to jpegtest>)
  • I built and compiled Pillow where it was installed on $HOME//.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages/Pillow-2.4.0-py2.7-linux-x86_64.egg . The important part of the output is as follows:

     *** TKINTER support not available --- JPEG support available *** OPENJPEG (JPEG2000) support not available --- ZLIB (PNG/ZIP) support available *** LIBTIFF support not available *** FREETYPE2 support not available *** LITTLECMS2 support not available *** WEBP support not available *** WEBPMUX support not available 

So, I would suggest that this means that JPEG support will work, but when I run my program, it says:

IOError: jpeg decoder not available

When typing, I also noticed that the question on Pillow was recognized by the JPEG encoder during installation, but was not using , which sounded very close to mine, so I tried the solution there

 ln -s /media/sdl1/home/midnight/jpegtest/lib/libjpeg.so /media/sdl1/home/midnight/.pythonbrew/pythons/Python-2.7.5/lib 

But I still have the same error.

I have been working on this issue for about two days now, and I'm not quite sure what to do. If someone can provide some help, it will be very helpful.

+6
source share
1 answer

Instead of just loading the libraries you need, try creating the entire Python environment locally in your home folder:

 $ wget http://www.python.org/ftp/python/[desired version of Python].tgz $ tar xzf Python[version].tgz $ cd python-[version] $ ./configure $ make altinstall prefix=~ exec-prefix=~ 

Update your PATH variable so that the first local Python is executed:

 $ PATH = /home/user/[pathtopython]:$PATH 

Get a protocol from which other packages can be installed:

 $ curl https://bootstrap.pypa.io/get-pip.py > get-pip.py $ ./get-pip.py $ pip install pillow 

URLs may vary. You still have to modify setup.py - I haven't used this technique with C-like libraries, so I'm not sure.

+1
source

Source: https://habr.com/ru/post/970484/


All Articles