Jupyter Notebook Hacks

Thanks for this!!

Does anyone know how to check environment variables in Jupyter Notebook?

Try things like !echo $PATH

Pressing I twice interrupts the kernel – useful if its taking forever to run due to some bug in your code and you don’t want to kill the whole notebook instance.

1 Like

Pasting the below code in one of the cell and run once and now press ctrl-m and now every time you press ‘r’ it’ll run all the cell. If anyone has a simpler solution please share

%%javascript

Jupyter.keyboard_manager.command_shortcuts.add_shortcut('r', {
    help : 'run all cells',
    help_index : 'zz',
    handler : function (event) {
        IPython.notebook.execute_all_cells();
        return false;
    }}
);
3 Likes

Some handy notebook extensions:

Variable Inspector: You can look at all the variables in the env and delete them
Code prettify: Formatting your code on a click of a button
Table of contents: Creates a table of content with hyperlinks based on the headings you have used in the notebook

3 Likes

Use full browser width! finally!

from IPython.core.display import HTML, display
display(HTML("<style>.container { width:100% !important; }</style>"))

Does anybody know how to fake a two column format?

1 Like

@shik1470 Can you tell us how to get these extensions? I can’t figure out how to get this window from jupyter notebook. Thanks.

literally just past that code into a python cell in jupyter notebook and run it. it’ll refresh the page and widen everything :slight_smile:

oh my! two column / tabbed output from Calysto notebook. Install per instructions then turn on

jupyter nbextension enable calysto/cell-tools/main --user

Then see the new icon and format:

you can go to this link to install nb extension (https://github.com/Anaconda-Platform/anaconda-nb-extensions) and then launch jupyter notebook after that.
Then go to edit and select nbextension shown below:

1 Like

try execute time extension…tells you the execution time of a cell without explicitly using time it

1 Like

Interesting jupyter behavior with class attributes, does anyone know why might be this happening …?

Thanks

You’re getting the caps versions from your class, and lowercase from superclass, AFAICT.

1 Like

As a Windows user, I’ve been frustrated by having to replace all of the Unix commands, for example I have to change this line !ls {PATH} in EVERY notebook os.listdir(PATH)). However, these commands are super useful! So wouldn’t it be nice if we could add them to windows?

Turns out, Cygwin adds these useful Unix commands (ls, pwd, cat, and many more…) to the Windows command line.

Note: the default installation adds a new terminal, but if you add Cygwin to your environment variables, then you get all of the commands in the standard command prompt! For me, the steps to do this were: search windows for ‘edit environment variables’ --> click Environment Variables… --> under System Variables, click the ‘Path’ variable --> click Edit --> add a new line C:\cygwin64\bin --> done!

Doesn’t windows have a full ubuntu shell now?

Yes, Ubuntu is available for windows 10 onwards.

Ubuntu on Windows allows one to use Ubuntu Terminal and run Ubuntu command line utilities including bash, ssh, git, apt and many more.

@parrt - Yes, but do you know how to access this Ubuntu command line from within Jupyter Notebook?

Most likely you have to start up Jupyter notebooks from the Ubuntu command line rather than Windows.

Ah - I didn’t mention this before but I’m running a local GPU and, for now, CUDA doesn’t run on Ubuntu on Windows (WSL).

So for the fastai’ers using Crestle/Paperspace/AWS - installing and launching fastai+Jupyter from WSL should work just fine (I just tested this out and had no problems running lesson 1).

Side note: apparently CUDA support is the most requested feature to add to WSL, although it is currently marked as being on backlog - here is the issue to find out if this changes.

1 Like