CoCalc offers several options for hosting running Jupyter Notebooks online.
A Jupyter notebook is a specific filetype with the ending
.ipynb, which records an interactive session with a Kernel.
It made up of cells, which can either store one or more lines of code or formatted text.
When you run a cell – which evaluates the piece of code in the cell via the active kernel session – you can see its output after the calculation is done.
This combination of communicating back and forth with a kernel and adding descriptive text makes this form of document very attractive.
There are many Kernels available, which allow you to choose the programming language and environment you want to work. A uite popular choice is Python3, but there are also SageMath and others. Our page on Jupyter Kernel Selection shows how to set the kernel.
Make sure and double-check that you’re working with a suitable kernel for your calculations!
The default client for Jupyter Notebooks on CoCalc is specific to this platform. It supports CoCalc’s advanced features, including real-time collaboration, side chat, and TimeTravel. Read more in our blogpost. The basic user interface looks like the following:
Above the main area is a menu bar and a button row:
- The menu bar contains all commands, and in particular the Kernel menu is for changing it if necessary.
- The button row gives you a one-click access to Run the current cell (otherwise press your Shift+Return keys), a way to restart the kernel (which clears the current session) and a Save button to make sure CoCalc has stored the file. The Time Travel button allows you to see previous versions of that notebook, such that you can go back in time to recover from a bad change.
- Active cell: in the screenshot above, the blue bar on the left and a blue border around a cell indicates that this is the currently active one. Actions like Run, Delete Cell, etc. operate on the currently selected cell. It is also possible to select more than one cell.
- Execution counter: On the left of each cell, there is an execution counter
In [ x ]. The number
xincreases each time a cell is being run. After the kernel stopped and restarted, that counter starts again at 1.
- The output of code cells is below the input cell. For example,
Out :is the output of cell
In :. In the right hand corner of the input cell is some information about how long it took to calculate the result.
- Text cells are slightly different. Select “Markdown” in the
[ Code ]dropdown menu in the button bar to change a code cell to such a markdown text cell. There, you can use Markdown to format the text. Similar to code-cells, either Run these text cells to see the processed Markdown code or press Shift+Return. To edit a text cell, either double click it or press your Return key.
- Saving: more general, the nice things about Jupyter Notebooks is that they save all your intput and output in one single file. This means you can download or publish the notebook as it is, and everyone else sees it in exactly the same way.
Jupyter Widgets are Python objects that let you build interactive GUIs for your Jupyter notebooks. CoCalc Jupyter notebooks combine the interactive capabilities of Jupyter widgets with the usual advanced features of the CoCalc platform, including real-time collaboration, TimeTravel, and side chat.
A good way to get started using Jupyter widgets is to go through the Widget List in the main widgets documentation.
If you are having trouble with the CoCalc Jupyter Notebook, you can switch to the Classical Jupyter Notebook. You can always switch back to CoCalc Jupyter easily later (and please let us know what is missing so we can add it!).
NOTE: The Classical Jupyter notebook is not supported in the Firefox browser. See Jupyter Server options below if you need to use Firefox and do not want to use the CoCalc Jupyter notebook.
You can change the default for opening a Jupyter notebook - CoCalc or Classical - by clicking the checkbox labeled “Jupyter classic …” in your Editor settings in Account Preferences.
To switch your notebook to Classical from within a CoCalc Jupyter notebook: select “File” → “Switch to Classical Notebook” in the menu.
To switch your notebook to CoCalc from within a Classical Jupyter notebook: select “File” → “Switch to Classical Notebook” in the menu.
- The main reasons to use the classical notebook are:
- need for certain extensions (Howto setup Jupyter Extensions).
- interactive widget support Note: as of April, 2019, CoCalc Jupyter notebooks support ipywidgets.
See our list of Jupyter related issues for more details.
Multiple people simultaneously editing the same notebook, with some using classical and some using the new mode, will NOT work! Switching back and forth will cause problems (you may need to use TimeTravel to recover). Please avoid using classical notebook mode if you possibly can!
Using either of these options for the classical notebook has an advantage: it does not affect your “Jupyter classic” Editor setting, allowing you to keep CoCalc Jupyter notebook as the default for opening .ipynb files in the CoCalc main interface.