SageMath 的主要仓库
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.
Those who are impatient may use prebuilt Sage available online from any of
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.
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.
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 Sage on Windows using Docker (see below) or other virtualization solutions.
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.
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.
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.
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.
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.
[Linux, WSL] Install the required minimal build prerequisites:
Compilers: gcc, gfortran, g++, or other suitable C, C++, and
Fortran compilers. Sage's classical build checks for a C compiler that
can compile C99 code and a C++ compiler with C++11 support.
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.12 or newer with a full standard library installation.
Sage no longer builds its own copy of Python; you must provide a
system Python or another external Python installation.
Sage's ./configure currently requires Python >= 3.12 and < 3.15,
with modules including sqlite3, ctypes, math, hashlib,
socket, ssl, ensurepip, and zlib.
See the installation guide
for details on using a system or uv-managed Python.
We have collected lists of system packages that provide these build prerequisites. See, in the folder build/pkgs/_prereq/distros, the files arch.txt, debian.txt (also for Ubuntu, Linux Mint, etc.), fedora.txt (also for Red Hat, CentOS), opensuse.txt, slackware.txt, and void.txt, or visit https://doc.sagemath.org/html/en/reference/spkg/_prereq.html#spkg-prereq
Optional: It is recommended that you have both LaTeX and the ImageMagick tools (e.g. the "convert" command) installed since some plotting functionality benefits from them.
[Development] If you plan to do Sage development or otherwise work with ticket branches and not only releases, install the bootstrapping prerequisites. See the files in the folder build/pkgs/_bootstrap/distros, or visit https://doc.sagemath.org/html/en/reference/spkg/_bootstrap.html#spkg-bootstrap
Bootstrap the source tree using the following command:
$ make configure
(If the bootstrapping prerequisites are not installed, this command will download a package providing pre-built bootstrap output instead.)
Sanitize the build environment. Use the command
$ env
to inspect the current environment variables, in particular PATH,
PKG_CONFIG_PATH, LD_LIBRARY_PATH, CFLAGS, CPPFLAGS, CXXFLAGS,
and LDFLAGS (if set).
Remove items from these (colon-separated) environment variables that Sage should not use for its own build. In particular, remove items if they refer to a previous Sage installation.
[WSL] In particular, WSL imports many items from the Windows
PATH variable into the Linux environment, which can lead to
confusing build errors. These items typically start with /mnt/c.
It is best to remove all of them from the environment variables.
For example, you can set PATH using the command:
$ export PATH=/usr/sbin/:/sbin/:/bin/:/usr/lib/wsl/lib/
[macOS with homebrew] Set require
暂无开放 Issues,或尚未同步最近议题。