Ask Your Question

sage-8.9 fails compilation in Ubuntu 18.04

asked 2019-10-01 03:03:25 +0100

dsejas gravatar image

updated 2020-01-12 14:01:54 +0100

FrédéricC gravatar image

Hello, Sage community!

I just downloaded the sage-8.9 source code. I tried to compile it with Python 3, but the process stops with an error when trying to install matplotlib. The problem seems to be related to the fact that the installer is looking for libpng12, which is no longer available at Ubuntu 18.04's repositories. I get the following error message:

                 numpy: yes [version 1.16.1]
      install_requires: yes [handled by setuptools]
                libagg: yes [pkg-config information for 'libagg' could not
                        be found. Using local copy.]
              freetype: yes [version 2.9.1]
                   png: no  [The C/C++ header for libpng (png.h) could not
                        be found.  You may need to install the development
                 qhull: yes [pkg-config information for 'libqhull' could not
                        be found. Using local copy.]


                        * The following required packages can not be built:
                        * png
                        * Try installing png with `apt-get install
                        * libpng12-dev` and pkg-config with `apt-get install
                        * pkg-config`

Is there something I can do in the meanwhile?

Thanks in advance!

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted

answered 2019-10-07 04:22:55 +0100

dsejas gravatar image

Hello, Sage community. I was able to solve this problem just by using sudo apt-get install python, which installs python and python2 as synonyms. As of John Palmieri's comment, this seems to just install a prerequisite for the compilation. Unfortunately, I haven't been able to determine what this dependency is.

edit flag offensive delete link more

answered 2019-10-01 07:59:41 +0100

eric_g gravatar image

On Ubuntu 18.04, you should install the Ubuntu package libpng16-16 prior to SageMath installation.

edit flag offensive delete link more


Hello, @eric_g. Forseeing the compilation of SageMath, I already had installed libpng16-16. Even so, the compilation fails.

dsejas gravatar imagedsejas ( 2019-10-01 21:21:15 +0100 )edit

Maybe install libpng-dev in addition? That should contain the header file png.h which matplotlib is complaining about.

John Palmieri gravatar imageJohn Palmieri ( 2019-10-01 23:05:03 +0100 )edit

I've just compiled successfully Sage 8.9 (Python 3 version) from scratch on a Ubuntu 18.04 computer. The only png-related package installed on that computer is libpng16-16 (in particular, libpng-dev is not installed). So I am puzzled by your issue. If this might be helpful, here are the steps of what I've done:

git clone
cd sage
make configure
./configure --with-python=3
MAKE="make -j16" make
eric_g gravatar imageeric_g ( 2019-10-04 17:34:09 +0100 )edit

Hello, @eric_g! Do you, by any chance, happened to have installed python and/or python2 before making make? I could solve my problem by installing those two packages previous to the compilation.

dsejas gravatar imagedsejas ( 2019-10-07 04:13:41 +0100 )edit

@dsejas Yes indeed the Ubuntu package python was installed on my computer prior to Sage build.

eric_g gravatar imageeric_g ( 2019-10-07 10:24:56 +0100 )edit

answered 2019-10-01 05:39:28 +0100

Try ./sage -f libpng (to force installation of Sage's version of libpng) and then make.

edit flag offensive delete link more


One question: I was using the following flow of commands to compile:

make configure
./configure --with-python=3
make build

Does your suggestion fit in this process? Where in the previous process should I use the command you suggest?

dsejas gravatar imagedsejas ( 2019-10-01 06:01:00 +0100 )edit

After the build has failed, execute ./sage -f libpng and then make (or make build, if you prefer).

John Palmieri gravatar imageJohn Palmieri ( 2019-10-01 06:25:13 +0100 )edit

Hello, @JohnPalmieri. I proceeded as you suggested, and I got stuck on the SciPy compilation. The problem seems to be that Openblas can't be found. I suppose that---extrapolating your suggestion---I can run ./sage -f openblas. However, this makes me wonder why I have those problems even if I have both libpng and openblas installed on my system.

dsejas gravatar imagedsejas ( 2019-10-01 21:25:28 +0100 )edit

Maybe you need the -dev versions of these packages, e.g. libopenblas-dev. Maybe Sage's method of detecting whether a package needs to be installed needs some work: maybe it's detecting openblas but it should be looking for libopenblas-dev.

John Palmieri gravatar imageJohn Palmieri ( 2019-10-01 23:06:47 +0100 )edit

Actually, Sage should be installing its own version of openblas regardless, it seems to me. Maybe the system version is interfering, and this might be remedied by installing the dev version.

John Palmieri gravatar imageJohn Palmieri ( 2019-10-01 23:17:47 +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


Asked: 2019-10-01 03:03:25 +0100

Seen: 511 times

Last updated: Oct 07 '19