Ask Your Question
1

How to fix "IOError: decoder jpeg not available"

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

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 -0600 )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
math.mks@yandex.com gravatar imagemath.mks@yandex.com ( 2018-08-17 22:40:38 -0600 )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 08:56:27 -0600 )edit

1 answer

Sort by » oldest newest most voted
1

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

tmonteil gravatar image

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

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 -0600 )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 -0600 )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 -0600 )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
math.mks@yandex.com gravatar imagemath.mks@yandex.com ( 2018-08-17 22:36:27 -0600 )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 -0600

Seen: 37 times

Last updated: Aug 09