6

Before someone says "sudo apt-get install libjpeg-dev" or something along those lines, I do not have sudo access. I am on a slice of a server that does NOT allow me to have sudo access. So I've gotta do this entire thing in my local directory. That's the only way I can do it.

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

Here are the steps I've taken so far:

  1. Downloaded libjpeg-dev and installed it to $HOME/jpegtest, so inside the jpegtest/ folder is lib/, include/, and so on
  2. I downloaded Pillow manually and extracted it out to $HOME/Pillow
  3. I edited the setup.py fild so the JPEG_ROOT to a libinclude(<absolute path to jpegtest>)
  4. I built and compiled Pillow, where it installed to $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 assume that this means JPEG support will function, but when I run my program it says:

IOError: decoder jpeg not available

While typing this I also noticed the question at Pillow recognizes JPEG encoder on install, but not use, 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've been working on this problem for about two days now, and I'm not entirely sure what to do. If anyone could offer some assistance, that would be very helpful.

3
  • Maybe try ldd as in this answer stackoverflow.com/a/24397115/162768 and see what path it's looking for.
    – Jason S
    Commented Jul 31, 2014 at 23:21
  • Sounds like you should ask the sysadmin to install the libraries you need on the server root.
    – sundance
    Commented Aug 17, 2014 at 2:25
  • Are you sure that the Python interpreter you are using is from your Pythonbrew setup and not the basic OS included one (which might have Pillow compiled without JPEG support)?
    – Timusan
    Commented Aug 18, 2014 at 4:40

1 Answer 1

1

Instead of just downloading the libraries you need, try creating an entire Python environment in 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 your local Python is executed first:

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

Obtain pip, 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 might still have to modify setup.py - I haven't used this technique with C-like libraries so I'm not sure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.