How to install SageMath on Linux
UPDATE: don’t bother, just use sympy
I like to use Mathematica for data visualisation (I know, I know, it’s just what I’m used to after they taught it to us at undergrad). There’s a lot of issues with Mathematica—clunkiness, cost, Wolfram being a bit of an arrogant weirdo, how closed-off it all is—but the one that prompted me to move on was simply that my employer’s license wasn’t compatible with my version of Mathematica because my version was too new. There was absolutely no way to downgrade to an older version after searching for days and talking with Wolfram support, so that was that.
That all seemed kind of dumb so I decided to try out SageMath, which seems roughly to be a Python-based equivalent to Mathematica.
The installation instructions however are needlessly convoluted, spanning a page on their own site and a README on github and, in a single numbered list, mixing steps for different OSs, steps that are optional and steps that are necessary, steps for building via github or from source files, all with no clear distinction. This means you end up having to read through every point to ensure you don’t miss something.
The following worked on a Raspberry Pi 4B running Raspberry Pi OS ‘Bullseye’. But it’ll take like 12 hours 👍
- Install the prerequisites
sudo apt install bc binutils bzip2 ca-certificates cliquer cmake curl ecl eclib-tools fflas-ffpack flintqs g++ gcc gengetopt gfan gfortran glpk-utils gmp-ecm lcalc libatomic-ops-dev libboost-dev libbraiding-dev libbrial-dev libbrial-groebner-dev libbz2-dev libcdd-dev libcdd-tools libcliquer-dev libcurl4-openssl-dev libec-dev libecm-dev libffi-dev libflint-arb-dev libflint-dev libfplll-dev libfreetype6-dev libgc-dev libgd-dev libgf2x-dev libgiac-dev libgivaro-dev libglpk-dev libgmp-dev libgsl-dev libhomfly-dev libiml-dev liblfunction-dev liblinbox-dev liblrcalc-dev liblzma-dev libm4ri-dev libm4rie-dev libmpc-dev libmpfi-dev libmpfr-dev libncurses5-dev libntl-dev libopenblas-dev libpari-dev libpcre3-dev libplanarity-dev libppl-dev libprimesieve-dev libpython3-dev libqhull-dev libreadline-dev librw-dev libsingular4-dev libsqlite3-dev libssl-dev libsuitesparse-dev libsymmetrica2-dev libz-dev libzmq3-dev libzn-poly-dev m4 make nauty openssl palp pari-doc pari-elldata pari-galdata pari-galpol pari-gp2c pari-seadata patch perl pkg-config planarity ppl-dev python3 python3-distutils r-base-dev r-cran-lattice singular singular-doc sqlite3 sympow tachyon tar tox xcas xz-utils dvipng ffmpeg imagemagick
- Set build directory
SAGE_ROOT=~/sage/sage-x.y
-
Go to https://www.sagemath.org/download-source.html, select a mirror, and download the file
sage-x.y.tar.gz
(wherex.y
is version number). -
Put that in
~/sage
, then unpack it
mkdir ~/sage
mv ~/Downloads/sage-x.y.tar.gz ~/sage/
cd ~/sage
tar xf sage-x.y.tar.gz
- Go inside newly-created directory and build it
cd sage-x.y
./configure
make
- Try it out
./sage
- Open a notebook
sage -n jupyter
and if that doesn’t work, then do this (2 hours)
sage -i notebook
and then you can
sage -n jupyter