Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Thanks for these Tips! Initially it seemed that 9.1 doesn't have the export function because a) I again have to specify --ip to get rid of an error message but then b) there is nothing for the browser. After struggling with v8.9 (compilation failed on my openSuse, but the Ubuntu tarball did it) I realized that the behaviour is just the same.

That said, it seems to be a command line tool with little documentation on the options.

./sage -n export --ip= --list

creates a list of notebooks, e.g.

Unique ID       | Notebook Name
_sage_:0        | Welcome to the Sage Tutorial! -- Sage Tutorial v5.11

This works in 8.9 and 9.1 (even if compiled for Python3). From there I'm digging deeper, there seems to be no "batch" conversion. Following I did this for a batch conversion of all notebooks, creating descriptive names:

# go to a new space
mkdir ~/.sage/jupyter_notebooks 
cd ~/.sage/jupyter_notebooks 
# make a list of IDs and worksheet names
/opt/sage-9.1/sage -n export --ip= --list > sagenb_list.txt
# prepare the arguments for the conversion
cat sagenb_list.txt | tail -n +3 | awk '{$2="" ; print "--ipynb=\""$0".ipynb\" "$1}' > map_list.txt
# run the conversion (sequentially, use)
cat map_list.txt |xargs -L 1 /opt/sage-9.1/sage -n export

And then started the notebook server with

/opt/sage-9.1/sage -n jupyter --notebook-dir="~/.sage/jupyter_notebooks" --ip=

to view it in the browser at From my example above, the name of the exported notebook changed to

_sage_:0 Welcome to the Sage Tutorial! -- Sage Tutorial v5.11.ipynb

Magically I can even open them, but handling seems to be a bit different as well...I'll figure it out. Thanks again! :-)