Sage FAQ: Frequently Asked Questions

1. Introduction

1.1. What is Sage?

Sage is a comprehensive open-source mathematics software suite that has the mission statement "Creating a viable free open source alternative to Magma, Maple, Mathematica, and Matlab." See http://www.sagemath.org/ for more details.

2. Getting Sage

2.1. Can I try out Sage without downloading anything?

Yes! Go to http://www.sagenb.org/ and set up a free account. If you log in, you will be working on a free Sage notebook server that will work identically to the one you get with Sage.

2.2. How do I get a Sage program I can run immediately?

Go to http://www.sagemath.org/download.html and click on the link for the binary for your operating system.

2.3. How do I get the Sage source code?

Go to http://www.sagemath.org/src/ to download the tar archive for any release of Sage.

2.4. How do I get a previous release of Sage?

Go to http://www.sagemath.org/src/ to download the tar archive for any release of Sage.

3. Installing and running Sage

3.1. Wouldn't it be way better if Sage did not ship as a gigantic bundle?

This has been discussed over and over again and it plainly doesn't work.

3.2. How do I use the notebook with Firefox 3.0 beta 5?

There is a bug in Firefox 3.0 beta 5 that causes it to reject connections to the Sage notebook with the error "Certificate key usage inadequate for attempted operation. (Error code: sec_error_inadequate_key_usage)". One solution is to use a different browser, such as Firefox 2, Konqueror, Safari, Opera, or even Internet Explorer. Another solution is to run the notebook in insecure mode by using the command inotebook() instead of notebook(); then Firefox 3.0b5 will work. Finally, there is a rather tedious workaround:

  1. Go to a notebook with a certificate which fails
  2. Click on the warning sign next to the location bar, then "more information"
  3. Click "View Certificate", and go to the Details tab # Click "Export", and save the file to your local machine
  4. Open Firefox Preferences -> Advanced -> Encryption

  5. Click "View Certificates", then "Import"
  6. Import the file that you saved in step 4
  7. Reload the notebook, you should see another warning message, which has a link "Or you can add an exception..." and the rest is straightforward.

3.3. How do I compile the source to Sage?

Download the source tar archive, extract the archive, change your directory to be inside of it, and read the README.txt file there. Basically, after making sure you have the proper prerequisite tools installed, you type make.

3.4. How do I run Sage on a platform other than VMWare or Windows?

Change your directory to the sage directory and run ./sage

To start an online notebook server, start Sage and type notebook() at the sage command prompt.

3.5. How do I run Sage with VMWare?

You must install the VMWare software (the free VMWare Player should work). Simply start the virtual machine using the VMWare software, wait for the virtual machine to boot up, then type notebook at the prompt.

3.6. How do I run Sage in Windows?

Windows is currently supported via the VMWare image, so see the instructions for running Sage under VMWare. See windows for information on efforts to make a native port of Sage to Windows.

3.7. How do I run a parallel build?

export MAKE="make -j8" will enable 8 threads for parts of the build that support parallelism.

3.8. How do I run Sage in a browser that is not the system default

Issue this command "env SAGE_BROWSER=opera /usr/bin/sage -notebook" either from the command prompt or as a menu command for Sage. Assumes a Linux operating system, Opera as the browser, and I happen to use KDE as my desktop.

3.9. How to get Sage's Python to recognize my system's Tcl/Tk install?

It may be that you have Tcl/Tk installed and that your system's Python recognizes it but Sage's Python does not. To fix that, install the tcl/tk development library. On Ubuntu, this is the command

sudo apt-get install tk8.5-dev

Next, reinstall Sage's Python:

sage -f python-2.5.2.p8

This will pick up the tcl/tk library automatically. If

sage: import _tkinter
sage: import Tkinter

does not raise an ImportError then it worked.

3.10. I'm seeing an error about 'Permission denied' on a file called sage-flags.txt

When sage is built from source, it keeps track of what special instructions your CPU supports (such as SSE2), and records these (so that if you try running the code on a different machine, which doesn't support these extra instructions, you get a sensible error message instead of a segfault or illegal instruction). Since this should be stored with sage itself (as opposed to a user's .sage directory), it has to be created by someone with the appropriate permissions.

So if you're seeing something like this:

Traceback (most recent call last):
  File "/usr/local/sage-4.0.2/local/bin/sage-location", line 174, in <module>
    t, R = install_moved()
  File "/usr/local/sage-4.0.2/local/bin/sage-location", line 18, in install_moved
    write_flags_file()
  File "/usr/local/sage-4.0.2/local/bin/sage-location", line 82, in write_flags_file
    open(flags_file,'w').write(get_flags_info())
IOError: [Errno 13] Permission denied: '/usr/local/sage-4.0.2/local/lib/sage-flags.txt'

it probably means that you compiled/installed sage as one user, but haven't run it to let it generate the sage-flags.txt file. Just run sage one time as whatever user installed it, and this problem should go away. This would also be easy to fix by having sage run once as part of the install process; see trac #6375 for this fix.

4. Developing in Sage

4.1. What tools do I need to develop in Sage?

You need the prerequisite tools listed in the README.txt file in the root directory of Sage.

4.2. Where is the source code to Sage?

You can browse the complete source code to everything in Sage at http://hg.sagemath.org/. This is a web interface to the Mercurial repository. The main source files are at http://hg.sagemath.org/sage-main?cmd=manifest;manifest=-1;path=/sage/. The other directories include docs directories, the package system, etc.

5. Working in Sage

5.1. Why is Sage's command history different than Magma's

press down arrow key, then the next line in history is fetched. This feature allows me to fetch as many successive lines in history as like. Does Sage(or readline) have a similar feature?

5.2. Type issues using scipy, cvxopt or numpy from Sage

Unfortunately, Numpy support of these advanced Sage types like Integer or RealNumber is not yet at 100%.

As a solution, redefine RealNumber and/or Integer to change the behavior of the Sage preparser, so decimal literals are floats instead of Sage arbitrary precision real numbers, and integer literals are Python ints. For example:

sage: RealNumber=float; Integer=int
sage: from scipy import stats
sage: stats.ttest_ind(list([1,2,3,4,5]),list([2,3,4,5,.6]))
(array(0.076752955645333687), 0.940704902474)
sage: stats.uniform(0,15).ppf([0.5,0.7])
array([  7.5,  10.5])

Alternatively, be explicit about data types, e.g.

sage: stats.uniform(int(0),int(15)).ppf([float(0.5),float(0.7)])
array([  7.5,  10.5])

As a third alternative, use the raw suffix:

sage: stats.uniform(0r,15r).ppf([0.5r,0.7r])
array([  7.5,  10.5])

Disabling the preprocessor is also achievable in code by preparse(False). One may start IPython alone from the command line ("sage -ipython") which does not pre-load anything Sage-specific; or switching the Notebook language to "python".

5.3. How do I save an object so I don't have to compute it each time I open a worksheet?

The save and load commands will save and load an object, respectively. In the notebook, the DATA variable is the location of the data storage area of the worksheet. To save the object my_stuff in a worksheet, you could do save(my_stuff, DATA+"my_stuff") and to reload it, you would just do my_stuff = load(DATA+"my_stuff")

5.4. I get an error from jsMath or the math symbols don't look right when displaying in the notebook

If you see the error "It looks like jsMath failed to set up properly (error code -7). I will try to keep going, but it could get ugly.", you haven't installed the TeX fonts which help jsMath render beautiful mathematics. To get the nice TeX display with jsMath, please download a set of fonts from here:

http://www.math.union.edu/~dpvc/jsMath/download/jsMath-fonts.html

If you are on Linux/Unix, ignore the instructions on the page and just unzip the fonts into your ~/.fonts directory. You can also install the "jsmath-fonts" package.

6. Getting help

6.1. How do I get help?

Sage has two very active email lists: http://groups.google.com/group/sage-devel and http://groups.google.com/group/sage-support. There are also two very active IRC channels: #sage-devel and #sage-support on freenode. Many developers also actively blog and also post other Sage-related tutorials and talks. See http://www.sagemath.org/help.html for a listing of these resources.

7. Other questions













rm spkg/installed/mpir* spkg/installed/atlas*
make

More explanation. The binaries have been built for a newer architecture than you have. Nobody has yet figured out how to build Sage in such a way that MPIR and ATLAS work on all hardware. This will eventually get fixed.







If you do need to escape to a shell, you can run the following from inside sage (untested):

import os
os.execp('sh')

then use "sudo -s" to get a root shell.






ToDo