I'm new to both Sage and Python. For writing sage program, I went to sagemath cloud, and when I tried to create a new file, I had, among others, two options: sage worksheet and IPython notebook. I noticed both does coloring and indentation. But I was wondering: is there any way to take advantage of both of them together? How can I combine both of them together? For example, in IPython notebook, how can I make it understand the sage commands?
To give an explicit and concrete example of the above, in Sage tutorials, there's factor(-2007). If you run it on sage worksheet, it gives (as you expect), -1*3^2*223, but in IPython notebook, it shows 'factor' is not defined. How can I write factor(-2007) in IPynb, run it, and get -1*3^2*223?
I'm working in a windows 8, 64 bit environment, just if it is relevant.
Going forward, Jupyter will contain the language-agnostic projects that serve many languages. IPython will continue to focus on Python and its use with Jupyter. Jupyter's architecture includes frontends (web or console) and backends (kernels for various languages). IPython console is only about Python and terminal.
Jupyter Notebook (formerly IPython Notebook) is a web-based interactive computational environment for creating, executing, and visualizing Jupyter notebooks.
For added convenience, it is possible to link your installation of SageMath into your Jupyter installation, adding it to the list of available kernels that can be selected in the notebook or JupyterLab interface. to find the location of the SageMath kernel description.
On a machine with everything properly configured, e.g., https://cloud.sagemath.com, you can just type
%load_ext sage
into an IPython notebook cell, and then you can use Sage (except plotting graphics might not work yet). I've attached a screenshot showing this. (NOTE: I've edited this answer, but not the screenshot -- the extension used to be more complicated.)
Note: the IPython notebook is now the Jupyter notebook.
To use Sage in a Jupyter notebook worksheet, you can either
%load_ext sage
, or%load_ext sage
.To change kernel, use the Kernel > Change Kernel
menu item, from
the menu bar that has File
, Edit
, View
, Insert
, Kernel
, Help
.
Also, there is now a native SageMath installer for Windows, which you can get from
and which works with any 64-bit Windows.
This will let you use SageMath using the Sage REPL (or command-line interface), or the Jupyter notebook, or the legacy SageNB notebook.
You should also be able to install JupyterLab by opening a
Sage shell and running sage --pip install jupyterlab
, and
then you can launch JupyterLab by running sage -n jupyterlab
.
Similarly, sage -n jupyter
gives you the Jupyter notebook,
and sage -n sagenb
gives you the legacy SageNB notebook.
All this also works on CoCalc, the new name of SageMathCloud.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With