In this post we want to show how to install a sagemath kernel for jupyter so that we can use it with our system jupyter. My operating system is Ubuntu 20.04 and the latest version in this moment of writing is Sagemath 9.3
- Download the suitable version of sage from www.sagemath.org
- Extract it in one folder of your use. I typically use `~/usrlocal’. This may take a while
- You cd to the directory and run ‘./sage’ This will extract some files
- In the ~/.bashrc update the aliases (replace USERNAME):
alias sage=/home/USERNAME/usrlocal/sage-9.3-Ubuntu_20.04-x86_64/SageMath/sage
export SAGE_ROOT="/home/USERNAME/usrlocal/sage-9.3-Ubuntu_20.04-x86_64/SageMath/"
- You can now run sage from any terminal.
- You can follow the instructions on this link
In my case I had to do the following to make it run.
- First of all, my system wide default python (I run Ubuntu 20.04) was still python2.7 so I wanted to change to python3. After googling for a while the following aworked for me:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
- I had to update pip to the latest version.
- We can now install our preferred jupyter notebook. I installed many using the official docs
pip install notebook
pip install jupyterlab
pip install voila
- Now we can run the following to add the kernel:
sudo jupyter kernelspec install ./local/share/jupyter/kernels/sagemath #find the right path for you
- Finally, running jupyter-notebook or jupyter-lab from the command line allows for the following