Python3-based SageMath in CoCalc
SageMath is being ported to Python 3.
This is an ongoing effort, and some things might not work in the Python3-based SageMath.
If you already want to try it however, there are several ways to go:
just copy a folder to a CoCalc project of yours,
or build from source in CoCalc,
or build from source elsewhere.
Here we document the first two options.
For the third option, see the "Installation from source" section of the Sage installation manual:
Get started by copying a folder to your project
In CoCalc, just copy this folder to your project:
In a CoCalc terminal, you can then use Python3-based SageMath by typing:
which will give you the famous Sage prompt
at which you can type any Sage command.
To add a "Sage Py3" Jupyter kernel to your project, we follow instructions adapted from the "Custom Jupyter Kernel" page on the CoCalc wiki:
Here, just run the following in a CoCalc terminal
and then replace the content of kernel.json
by:
Now if you open a Jupyter notebook worksheet (file ending in .ipynb
), you can select the "Sage Py3" kernel from the "Kernel > Change kernel" menu.
Or build from source
Instead of copying a ready-to-go Sage folder as above, you might prefer to build from source. Here is how to do that.
In a CoCalc project with internet access and some extra disk space, open a terminal.
If your project has many cores (say 4) and you want to build in parallel, first run the following command (replacing 4
by the number of cores available):
Or you could edit your .bashrc
, adding the following line to it.
and then either close the terminal and open it again, or run
Once you have set MAKE
as above (or skipped that), run:
You can then try:
and try your favourite Sage commands, see if they work!
You can also install a "Sage Py3" Jupyter kernel, by following the instructions at the end of the previous section.