CoCalc offers several options for hosting running Jupyter Notebooks online.
They’re 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.
Make sure and double-check that you’re working with a suitable kernel for your calculations!
The default editor for Jupyter Notebooks on CoCalc is specific to this platform and has a couple of tightly integrated features (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.
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!).
- From within an existing classical Jupyter notebook: click the button “CoCalc Jupyter Notebook”, or
- from within a CoCalc Jupyter notebook: select “File” → “Switch to Classical Notebook” in the menu, or
- Click the checkbox labeled “Jupyter classic” in your Editor settings in Account.
- As of October 2017, the main reasons to use the classical notebook are:
- interactive widget support
- reading interactive input at least 3 times
- need certain extensions (Howto setup Jupyter Extensions).
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.