Ask Your Question
1

How to fix "IOError: decoder jpeg not available"

asked 2018-08-09 06:08:18 -0500

I have stuck when I compile these code in SageNotebook:

from PIL import Image
img=Image.open("/home/pmath/Music/im1.jpg") 
img2=img.convert("L")
img2.save("/home/pmath/Music/secretimage.pgm")
img=Image.open("/home/pmath/Music/secretimage.pgm")
pix=img.load()
print pix

The following errors occur :

Traceback (click to the left of this block for traceback)
...
IOError: decoder jpeg not available

But when I compile these codes with python on the same OS(ubuntu32bit 16.04) it works well. The problems occur only on Sage. How can i fix this issue?

edit retag flag offensive close merge delete

Comments

How did you install Sage? Did you build it from source? Did you download a binary for your OS?

slelievre gravatar imageslelievre ( 2018-08-10 10:54:58 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-08-09 09:34:55 -0500

tmonteil gravatar image

updated 2018-08-09 10:59:11 -0500

The problem comes from the fact that pillow is built without jpeg support (no idea why), see the file SAGE_ROOT/build/pkgs/pillow/spkg-install: https://git.sagemath.org/sage.git/tre...

If you want to fix the issue, and if you built Sage from source, you can :

  • install the (ubuntu) package libjpeg-dev
  • remove the line --disable-jpeg \ line in SAGE_ROOT/build/pkgs/pillow/spkg-install
  • recompile pillow with sage -f pillow
edit flag offensive delete link more

Comments

@tmonteil First of all thank you for your answer. According to you I have installed the (ubuntu) package libjpeg-dev, but the problem still remains. I have not found "https://git.sagemath.org/sage.git/tree/build/pkgs/pillow/spkg-install" in my OS.

math.mks@yandex.com gravatar imagemath.mks@yandex.com ( 2018-08-09 23:08:43 -0500 )edit

If the directory of your Sage installation is /home/pmath/SageMath, then the file you are looking for is at /home/pmath/SageMath/build/pkgs/pillow/spkg-install. If the directory of your Sage installation is /opt/sagemath/, then it is at /opt/sagemath/build/pkgs/pillow/spkg-install. Etc.

slelievre gravatar imageslelievre ( 2018-08-10 10:56:40 -0500 )edit

To determine where the directory of your Sage installation is, you can run this command inside Sage:

sage: print(SAGE_ROOT)
slelievre gravatar imageslelievre ( 2018-08-10 10:57:41 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-08-09 06:08:18 -0500

Seen: 23 times

Last updated: Aug 09