Ask Your Question
1

How to fix "IOError: decoder jpeg not available"

asked 2018-08-09 13:08:18 +0100

updated 2019-08-26 21:16:02 +0100

FrédéricC gravatar image

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 17:54:58 +0100 )edit

@slelievre I have installed Sage using the following terminal commands :

sudo apt-add-repository -y ppa:aims/sagemath
sudo apt-get update
sudo apt-get install sagemath-upstream-binary
BSFU gravatar imageBSFU ( 2018-08-18 05:40:38 +0100 )edit

The aims/sagemath repository is no longer kept up-to-date.

Where did you find instructions to install Sage that way?

Which version of Sage did this get you? Sage 7.6?

There is now a Debian package, which you can install in Debian >= 9 and also in Ubuntu >= 18.04.

Just do

sudo apt-get install sagemath-jupyter

This will install Sage 8.1 and soon should offer Sage 8.3.

slelievre gravatar imageslelievre ( 2018-08-18 15:56:27 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2018-08-09 16:34:55 +0100

tmonteil gravatar image

updated 2018-08-09 17:59:11 +0100

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.

BSFU gravatar imageBSFU ( 2018-08-10 06:08:43 +0100 )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 17:56:40 +0100 )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 17:57:41 +0100 )edit

@sleliere the Sage installation directory is : /usr/lib/sagemath, But there is no file "SAGE_ROOT/build/pkgs/pillow/spkg-install". Here is the list through terminal command

mks@mks-H81M-S:/usr/lib/sagemath/build$ ls
make
BSFU gravatar imageBSFU ( 2018-08-18 05:36:27 +0100 )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 13:08:18 +0100

Seen: 662 times

Last updated: Aug 09 '18