Ask Your Question

Built from src on Raspberry Pi 4: No module named 'sage' error

asked 2020-07-31 20:42:08 +0200

anmig gravatar image


Recently I built sage from source on my Raspberry Pi 4. Everything seemed to compile fine except a couple of items (posted below). However, when I go to run ./sage, I get the following error:

Traceback (most recent call last):
  File "/home/pi/src/sage-9.1/src/bin/sage-ipython", line 9, in <module>
    from sage.misc.banner import banner
ModuleNotFoundError: No module named 'sage'

Running grep -li "^Error" logs/pkgs/* yields,


So, is the fact that these three could not build the problem? I read somewhere that make will stop if such errors are encountered. I'm new to the compile from source world, so the use of ./configure and make are somewhat confusing to me.

Anyways, if you need any further information from these logs or anything else regarding my setup that could be of use, please let me know. I appreciate any help you can offer.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-07-31 22:25:50 +0200

slelievre gravatar image

Here is a quick overview of how to compile Sage from source.

See also the official "install SageMath from source" guide.

  • install the necessary prerequisites

  • get the Sage source files

    • either using Git:

      $ git clone --single-branch --branch develop --tags
    • or by downloading from the SageMath development release download page

      • using a web browser
      • or using curl or wget

      and extracting the downloaded archive

      • by double-clicking it
      • or in the terminal with

        $ tar xf sage-X.Y.betaZ.tar.gz
  • change to the directory obtained above

    $ cd sage  # or:  cd /path/to/extracted/directory/
  • in the terminal, run the following commands

    • select the develop branch and update it

      $ git checkout develop
      $ git pull origin develop --tags
    • check the current branch and what remote branch it is tracking

      $ git branch -vv
    • select the number of jobs to run in parallel

      $ MAKE='make -j1'  # or -j4 to build with 4 jobs in parallel, etc.
    • run the configuration script

      $ make configure
      $ ./configure

    Note that this will end with a suggestion of extra packages to install. Follow these instructions for Sage to use those system packages! Doing can make building Sage take a lot less time and energy.

    • finally, build Sage

      $ make -s V=0

Once all that is done

  • if the build fails, it will say what packages failed to build

  • if all goes well, the output will end with something like

    Testing that Sage starts...
    [2020-07-31 20:42:27] SageMath version 9.2.beta6, Release Date: 2020-07-25
    This looks like the first time you are running Sage.
    Cleaning up, do not interrupt this.
    Done cleaning.
    Yes, Sage starts.
    real    250m37.393s
    user    234m8.482s
    sys 20m59.096s
    Sage build/upgrade complete!

If all went well, optionally, run Sage tests with one of

$ make test
$ make testlong
$ make testall
$ make testalllong
$ make ptest
$ make ptestlong
$ make ptestall
$ make ptestalllong

(see the SageMath developer guide for the differences between those).

That will take some time! In the end,

  • files with failing doctests or timeouts will be listed

  • or the joyous "All tests passed!" will appear!

To provide regular reports of success or failure of building and testing on Raspberry Pi, ideally,

  • subscribe to the sage-release mailing list

  • post your reports as a reply to the release manager's announcement for the appropriate development release (currently SageMath 9.2.beta6).

    For instance, if your success or failure to build was with SageMath 9.2.beta6, reply to Volker Braun's post "Sage 9.2.beta6 released".

edit flag offensive delete link more


Thank you for the thorough overview. Just as an aside, I did follow the official documentation when building. The version is 9.1. However, I noticed that some of the steps you provided differ slightly from what I had come across there. Particularly regarding git, since I didn't use the git repo, but some mirror on the sage site. Furthermore, I also ran make with tests, but again, am too unfamiliar with everything to know what was going on. Looking at my install.log, it says "Error building Sage" and that fplll-5.3.2 and giac- failed to build.

Just wanted to make note of that here for anyone else with similar problems. I will do as you recommend and subscribe to the mailing list to post further issues on this matter.

Thank you.

anmig gravatar imageanmig ( 2020-08-01 01:11:02 +0200 )edit

Note: here are a few relevant tickets for the issues you faced.

The failure to build fplll on Raspberry Pi is discussed at

where the discussion mentions this was fixed by

which was merged in Sage 9.2.beta4, so no wonder Sage 9.1 failed to build.

This also means building Sage 9.2.beta6 should work for you!

I would suggest always using the latest development release rather than the latest stable release.

What ticket #29091 does is add a way to automatically test that things work on Raspbian-buster so we don't go back to it not working in the future.

slelievre gravatar imageslelievre ( 2020-08-01 02:27:02 +0200 )edit

Note: one can also search tickets whose summary or description match "raspb":

slelievre gravatar imageslelievre ( 2020-08-01 02:32:36 +0200 )edit

From the point you have reached, ie, downloaded sources for Sage 9.1 and built a number of packages already, I would do

$ git pull origin develop --tags
$ git checkout develop
$ git branch -vv

and see if that says something like 9.2.beta6, and if so do

$ make configure
$ ./configure
$ make -s V=0

and that should get you where you need without having to start over from scratch.

slelievre gravatar imageslelievre ( 2020-08-01 02:43:29 +0200 )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


Asked: 2020-07-31 20:42:08 +0200

Seen: 505 times

Last updated: Jul 31 '20