Installing Sage
- Go to the Official Sage Installation Page.
- In the line Linux macOS Windows, click on your operating system.
- The instructions below are for your convenience only. Compare to the official documentation when running, and let me know if there are any changes, differences, or issues.
Installing in Windows
Follow the instructions at https://doc.sagemath.org/html/en/installation/index.html
This involves installing and activating the Windows Subsystem for Linux (WSL). This will take a little time, but will provide you access to a full linux distribution inside Windows.
-
Install Ubuntu Linux on WSL
- Option 1: Open the Windows Store and search for Ubuntu
-
Option 2: Open the
PowerShellapplication and runwsl --install -
Reboot your machine if needed
-
Search your Start Menu for
Ubuntu. Right click and selectadd link to taskbarso you can find this more easily. Then left click to open it. -
Inside
Ubunturun the commands from the official Sage Math installation page. The code at the time of writing is given below, but check the official page and use their code insteadcurl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" bash Miniforge3-$(uname)-$(uname -m).sh conda create -n sage sage python=3.12 conda activate sageYou may need to hit
Enterto answer several questions. It should be safe to accept the default options. -
To run Sage, first open Ubuntu. Then run the following command:
sage -n jupyterRead the output very carefully. You will see a line that looks says
To acess the server, open this file in a browser:, followed by one or more addresses like the following:http://localhost:8888/tree?token=8da1...097dCopy the entire address into a web browser, and load it.
Installing in macOS
Follow the instructions at https://doc.sagemath.org/html/en/installation/index.html
It is easist to use the binary build files. According to SageMath, it is signed and notarized for use with the macOS ecosystem.
- If you have a M1, M1X or M2 processor select the
...arm64.dmgfile - If you have an Intel processor select
...x86_64.dmg
After downloading, install it by opening it, and dragging the SageMath icon to the Applications folder.
Running Sage in a Jupyter Notebook
Windows Reminder
To load Sage, first open Ubuntu. Then run the following command:
sage -n jupyter
Read the output very carefully. You will see a line that looks says
To acess the server, open this file in a browser:, followed by one or more addresses like the following:
http://localhost:8888/tree?token=8da1...097d
Copy the entire address into a web browser, and load it.
Starting Sage
If prompted when opening Sage, you want to run it using a Jupyter Notebook.
- Windows: Open
Ubuntu, then runsage -n jupyter - macOS: Click on the application icon.
When you open it for the first time, you will see your user directory.
- Windows, if your username is
jdoe, this will beC:\Users\jdoe. - macOS, (Todo: check this)
You can open an existing notebook (with a .ipynb extension), or you can create a new one.
When you create a notebook, you will be prompted for the kernel.
- Select Sage as your kernel if you want to run Sage code.
- You can also select Python as your kernel if you want to run pure Python code.
Understanding the Jupyter Notebook Interface
- File commands:
- save file
- Cell commands
- insert blank cell
- cut/copy/paste cell
- run current cell
- Runtime commands
- stop execution
- restart kernel
- restart and run all cells
- There is a Dropdown that lets you select code or markdown.
- Code cells contain code that is executed when you click run
- Markdown cells contain text that is nicely formatted when you click run
- At the far right, you will see SageMath 10.7. This tells you the existing Kernel. You use a Sage kernel to run Sage code, and a Python kernel to run pure Python.