SkillAgentSearch skills...

Sage

Main repository of SageMath

Install / Use

/learn @sagemath/Sage
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<div> <a href="https://sagemath.org"> <picture> <source media="(prefers-color-scheme: dark)" srcset="src/doc/common/static/logo_sagemath_white.svg"> <img src="src/doc/common/static/logo_sagemath_black.svg" height="60" align="left"> </picture> </a> <em>"Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, and MATLAB"</em> </div>

Sage is open source mathematical software released under the GNU General Public Licence GPLv2+, and includes packages that have compatible software licenses. People all around the globe have contributed to the development of Sage. Full documentation is available online.

Table of Contents

Getting Started

Those who are impatient may use prebuilt Sage available online from any of

Binder   Gitpod Ready-to-Code   Open in GitHub Codespaces

without local installation. Otherwise read on.

The Sage Installation Guide provides a decision tree that guides you to the type of installation that will work best for you. This includes building from source, obtaining Sage from a package manager, using a container image, or using Sage in the cloud.

This README contains self-contained instructions for building Sage from source. This requires you to clone the git repository (as described in this README) or download the sources in the form of a tarball.

If you have questions or encounter problems, please do not hesitate to email the sage-support mailing list or ask on the Ask Sage questions and answers site.

Supported Platforms

Sage attempts to support all major Linux distributions, recent versions of macOS, and Windows (using Windows Subsystem for Linux or virtualization).

Detailed information on supported platforms for a specific version of Sage can be found in the section Availability and installation help of the release tour for this version.

We highly appreciate contributions to Sage that fix portability bugs and help port Sage to new platforms; let us know at the sage-devel mailing list.

[Windows] Preparing the Platform

The preferred way to run Sage on Windows is using Windows Subsystem for Linux (WSL). Follow the official WSL setup guide to install Ubuntu (or another Linux distribution). Make sure you allocate WSL sufficient RAM; 5GB is known to work, while 2GB might be not enough for building Sage from source. Then all instructions for installation in Linux apply.

As an alternative, you can also run Linux on Windows using Docker (see below) or other virtualization solutions.

[macOS] Preparing the Platform

  • If your Mac uses the Apple Silicon (M1, M2, M3, M4; arm64) architecture and you set up your Mac by transferring files from an older Mac, make sure that the directory /usr/local does not contain an old copy of Homebrew (or other software) for the x86_64 architecture that you may have copied over. Note that Homebrew for the M1 is installed in /opt/homebrew, not /usr/local.

  • If you wish to use conda, please see the section on conda in the Sage Installation Manual for guidance.

  • Otherwise, we strongly recommend to use Homebrew ("the missing package manager for macOS") from https://brew.sh/, which provides the gfortran compiler and many libraries.

  • Otherwise, if you do not wish to install Homebrew, you will need to install the latest version of Xcode Command Line Tools. Open a terminal window and run xcode-select --install; then click "Install" in the pop-up window. If the Xcode Command Line Tools are already installed, you may want to check if they need to be updated by typing softwareupdate -l.

Instructions to Build from Source

Like many other software packages, Sage is built from source using ./configure, followed by make. However, we strongly recommend to read the following step-by-step instructions for building Sage.

The instructions cover all of Linux, macOS, and WSL.

More details, providing a background for these instructions, can be found in the section Install from Source Code in the Installation Guide.

  1. Decide on the source/build directory (SAGE_ROOT):

    • On personal computers, any subdirectory of your :envvar:HOME directory should do.

    • For example, you could use SAGE_ROOT=~/sage/sage, which we will use as the running example below.

    • You need at least 10 GB of free disk space.

    • The full path to the source directory must contain no spaces.

    • After starting the build, you cannot move the source/build directory without breaking things.

    • You may want to avoid slow filesystems such as network file systems (NFS) and the like.

    • [macOS] macOS allows changing directories without using exact capitalization. Beware of this convenience when compiling for macOS. Ignoring exact capitalization when changing into :envvar:SAGE_ROOT can lead to build errors for dependencies requiring exact capitalization in path names.

  2. Clone the sources with git:

    • To check that git is available, open a terminal and enter the following command at the shell prompt ($):

        $ git --version
        git version 2.42.0
      

      The exact version does not matter, but if this command gives an error, install git using your package manager, using one of these commands:

        $ sudo pacman -S git                          # on Arch Linux
        $ sudo apt-get update && apt-get install git  # on Debian/Ubuntu
        $ sudo yum install git                        # on Fedora/Redhat/CentOS
        $ sudo zypper install git                     # on openSUSE
        $ sudo xbps-install git                       # on Void Linux
      
    • Create the directory where SAGE_ROOT should be established:

        $ mkdir -p ~/sage
        $ cd ~/sage
      
    • Clone the Sage git repository:

        $ git clone -c core.symlinks=true --filter blob:none  \
                    --origin upstream --branch develop --tags \
                    https://github.com/sagemath/sage.git
      

      This command obtains the most recent development release. Replace --branch develop by --branch master to select the most recent stable release instead.

      This will create the subdirectory ~/sage/sage. (See the section Setting up git and the following sections in the Sage Developer's Guide for more information.)

    • Change into the created subdirectory:

        $ cd sage
      
    • [Windows] The Sage source tree contains symbolic links, and the build will not work if Windows line endings rather than UNIX line endings are used.

      Therefore it is recommended (but not necessary) to use the WSL version of git.

  3. Install system packages.

    Either refer for this to the section on installation from source in the Sage Installation Manual for compilations of system packages that you can install. When done, skip to step 7 (bootstrapping).

    Alternatively, follow the more fine-grained approach below.

  4. [Linux, WSL] Install the required minimal build prerequisites:

    • Compilers: gcc, gfortran, g++ (GCC versions from 8.4.0 to 13.x and recent versions of Clang (LLVM) are supported). See build/pkgs/gcc/SPKG.rst and build/pkgs/gfortran/SPKG.rst for a discussion of suitable compilers.

    • Build tools: GNU make, GNU m4, perl (including ExtUtils::MakeMaker), ranlib, git, tar, bc, patch, bzip2, pkgconf (also known as pkg-config). See build/pkgs/_prereq/SPKG.rst for more details.

    • Python 3.4 or later, or Python 2.7, a full installation including urllib; but ideally version 3.12.x or later, which will avoid having to build Sage's own copy of Python 3. See build/pkgs/python3/SPKG.rst for more details.

    We have collected lists of system pac

Related Skills

View on GitHub
GitHub Stars2.3k
CategoryDevelopment
Updated1d ago
Forks837

Languages

Python

Security Score

80/100

Audited on Apr 5, 2026

No findings