Jupyter notebook opens slowly and extensions don't show up - [MathJax] issue - jupyter-notebook

I'm trying to open a jupyter notebook and it takes a long time and I see at the bottom it's trying to load various [MathJax] extension, e.g. at the bottom left of the safari browser it says:
Loading [MathJax]/extensions/safe.js
Eventually, the notebook loads, but the extensions I used to have, don't show up (like table of contents and others)
I tried to run nbstripout with the relevant filename but it didn't change anything.
I also tried to reinstall jupyter.

I'm having the same issue with timing (but my extensions all seem to work OK). After a lot of experiments with MathJax options in the Jupyter configuration file it seems to be... not related to MathJax.
My guess is that's the last notice displayed, and it stays there while the rest of the notebook loads.
In my experiments, the time to load is directly related to the number of cells in the notebook.

Related

How can I display a markdown reference/cheatsheet within JupyterNotebook

I could swear that several times when working in a Jupyter Notebook, I inadvertently hit some shortcut key that popped up a markdown cheatsheet, within the Notebook window, but I cannot figure out how to access this cheatsheet intentionally, via shortcut or menu. I've searched the Jupyter Notebook docs, but I'm not finding anything.
I am able to access a Markdown guide on GitHub, in a separate page, but not the cheatsheet that appears within the Notebook, similar to the way the "command palette" opens within the Notebook, as a pop-up. The latter is much handier, as it doesn't involve jumping back and forth between browser tabs.

JupyterHub - how to debug UI issues?

We use jupyterhub cluster and without any noticeable change on our side, the notebook cells' height turned huge and static (attached a picture)
Tried to fix the issue looking at - How do I increase the cell width of the Jupyter/ipython notebook in my browser?
Managed to decrease the cells size but it's still static.
Any suggestion what has might caused the change? And how to fix this?
This is how our cells look today -
Potential fixes
My suggestion to uninstall your extensions one-by-one until the problem goes away may honestly be the fastest way to get a fix. If have a reasonably recent version of Jupyter you can list all of your installed extensions with:
jupyter nbextension list
You would then start by uninstalling any extension that relates to theme and/or styling of the notebook. It's possible that list will miss some things (eg an improperly installed extension, or issues with your own config files). The next step (after getting rid of at least all suspicious extensions) would be to go through all of the user-space data and config files that Jupyter sets up in the background. You can get the paths to all directories containing such files by running:
jupyter --paths
Small note, you can probably ignore all files in the runtime dir, these probably aren't the problem.
If a mass uninstall of your extensions makes you squeamish, another option would be to debug the CSS of a live notebook and figure out exactly where the styling of the code cells is getting screwed up.
Detailed instructions for debugging the CSS
The following instructions are for Chrome, but if you're using another browser you should be able to figure out an equivalent:
start up a notebook
right click on a code cell and select "Inspect"
this will bring up a view of the DOM node hierarchy and highlight the node representing the code cell (or some at least some part of it) that you just right clicked on
on the right side of the screen will be a window with a bunch of tabs at the top. Select "Computed", which contains the style that is actually displayed in the browser, as computed from the sum of the effects of all CSS selectors
in particular, pay careful attention to the width and height properties of the computed style. Walk up and/or down the DOM hierarchy until you find a node with a suspicious looking width or height
If a value is greyed out, that means that it's being set in a parent node
start with a suspicious looking value, then go up the hierarchy until the values seem normal again
on one side of that transition point, you should have the top-most node in your hierarchy with bad values. If you examine the "Computed" tab, you should be able to see exactly which files are setting the bad values
The identity of the files screwing up your notebook styling is the payoff here. Examining those files should help you a great deal in uncovering the real problem.

Holoviews (Bokeh) with reveal.js

I have a presentation with Holoviews (Bokeh) interactive plots. The presentation works fine with rise (inside the notebook), but when I convert it to slides with reveal.js (v3.6.0) locally, the output doesn't show up. Even post serving through the CDN doesn't fix the issue. Anyone encountered this before?
I raised an issue on the RISE site about this problem once I was able to reproduce it, and the RISE author pointed me to this issue on the Bokeh site that let me get it working in my case. The solution is simply not to tell RISE to skip the cell that contains hv.extension("bokeh"). That cell loads BokehJS, which is needed for any Bokeh-based plots to show up, and skipping it works fine for a live presentation but apparently not for any exported version. After telling RISE not to skip that cell, my example notebook now works fine when converted to .html using jupyter nbconvert --to slides Bednar_INDEX_2018.ipynb, and it can be converted to PDF as described in the RISE documentation. The PDF output isn't formatted perfectly, but the plots do all show up at least.

Ctrl+P and Ctrl+N for navigation in jupyter notebooks

I'm used to Emacs navigation, in particular Ctrl+P, N, F, and B, but I'm also used to Jupyter notebooks by now. The general question is: how to enable those shortcuts in a notebook?
What tickles me is the fact that on Mac those keybindings are already in place in a standard Anaconda IPython. But it's perfectly understandable since most system and browser shortcuts are bound to Cmd instead of Ctrl.
Since I spend a lot of time in Ubuntu, I wanted to reproduce the same behaviour here. It soon became apparent that most browsers hold some of the keybindings very dearly, such as Ctrl+P for print or Ctrl+N for New window. Turning these off is a huge matter in itself, so I decided to use another browser solely for the Jupyter Notebook, and Vivaldi seems like a nice choice since all shortcuts are easily customizable there.
I believed that with browser shortcuts being turned off, the IPython syntax would kick in, but none such thing has happened. Next I tried one of many manuals on the Jupyter notebook shortcuts customization (such as this one http://jupyter-notebook.readthedocs.io/en/latest/examples/Notebook/Custom%20Keyboard%20Shortcuts.html) to bind the 4 shortcuts I need. It works only up to some extent and only in the Jupyter inline magic:
%%javascript
Jupyter.keyboard_manager.command_shortcuts.add_shortcut('ctrl-p', 'jupyter-notebook:move-cursor-up')
What it does is that occasionally now the cursor in command mode does indeed move up when I press ctrl-p, but this behaviour is unstable. Moreover, after it moves, it immediately enters the edit mode in the cell above, which isn't happening if I simply press 'Up' arrow. As for the same trick for the edit mode:
%%javascript
Jupyter.keyboard_manager.edit_shortcuts.add_shortcut('ctrl-p', 'jupyter-notebook:move-cursor-up')
alas, it doesn't work at all.
Forgive me for the prolonged intro. The questions I have now are:
What is wrong with the key bindings I use in inline mode? Is it a silly mistake I made or a Jupyter glitch?
When I try to use these byndings through my custom.js file, they do not work. However, the file itself is recognized, e.g. the alert() commands work perfectly fine.
I've stumbled a few times on a emacs-bindings for the CodeMirror, however, as far as I understood, they are mostly used for copy-paste related matters rather than navigation, is it true? Would it help to use this set of bindings instead of pursuing the path with custom.js?
Thank you.
UPD
Installing emacs.js from CodeMirror and adding this code actually solved my problem. Just had to make sure that all conflicting browser keybindings were turned off.
require(["codemirror/keymap/emacs", "notebook/js/cell", "base/js/namespace"],
function(emacs_keymap, cell, IPython) {
cell.Cell.options_default.cm_config.keyMap = 'emacs';
var cells = IPython.notebook.get_cells();
for(var c=0; c< cells.length ; c++){
cells[c].code_mirror.setOption('keyMap', 'emacs');
}
}
);

Jupyter Notebook: How to improve navigation experience over long page

I would like to be able to switch rapidly from one section of my Jupyter notebook to another section, I mean within the same .ipynb file, as these files tend to get long while exploring data.
Ideally, this will be possible by marking the scrollbar of the navigator. I was thinking using a mozilla firefox add-ons, like "Scrollbar Search Highlighter" or "Content Scrollbar", but I didn't find a way to use them within the Jupyter notebook context.
Any idea to improve Jupyter notebook experience related to long page navigation?
Jupyter notebook extensions (link) come with the Table of Contents extension, which allows you to conveniently navigate over the various sections of your notebook
Make use of nbextensions. From there you can enable Table of contents which finally look like this:
Table of contents is built-in JupyterLab by default now:
https://jupyterlab.readthedocs.io/en/stable/user/toc.html
Also available as the structure tab of DataSpell and Pycharm:
https://www.jetbrains.com/help/dataspell/guided-tour-around-the-user-interface.html#tool-windows

Resources