How-to: Share your jupyter notebook


How to share your notebook code so that others can assist you

Who is this for?

Anyone who needs help with their code, or just wants to share what they have done

How do I share my notebook?

You can post code snippets using three backticks, or using the preformatted text button in the edit window

Code snippets

But that doesn’t work very well for jupyter notebooks: they’re not rendered correctly.

Here are some better ways:

  1. GitHub gist + nbviewer

Once you have a link to your notebook post it into your topic to refer to your notebook. Note you can still post inline code snippets from the notebook to highlight specific code ideas, or changes.

@aidan thanks for this helpful info. Re option 2 (gist) how do I install gh on gadi? I followed instructions from here:

e.g: conda install gh --channel conda-forge
but got this error message:
Downloading and Extracting Packages

Preparing transaction: done
Verifying transaction: failed

EnvironmentNotWritableError: The current user does not have write permissions to the target environment.
environment location: /g/data3/hh5/public/apps/miniconda3/envs/analysis3-22.10
uid: 5564
gid: 3204

1 Like

You don’t need to install it, it is already in the condo/analysis3 environments:

$ which gh

FYI you got this error message because you’re trying to install into the conda/analysis3-22.10 environment, which you don’t have write permissions to, and shouldn’t. The best way to add a package that isn’t in the conda environments, and which the CLEX team don’t wish to add, is to use

pip install <packagename> --user

which will install it into your ~/.local directory. Note that this really only works successfully for pure python packages, i.e. packages which do not have external dependencies on compiled libraries.

A third option:


    Simply add your notebook to a public GitHub repo, along with an environment configuration file (e.g. an environment.yml specifying an Anaconda environment for your notebook). Enter the details of that repo at and you’ll be provided with a shareable link where people can actually run your notebook.

    (Note, is a community effort that relies on donors to provide cloud resources to run your notebooks. The project is currently at reduced capacity because one of the key funding sources has ended. If you use and like binder, maybe consider donating to the project.)

1 Like