181

I am trying to wrap my head around what I can/cannot do with Jupyter.

I have a Jupyter server running on our internal server, accessible via VPN and password protected.

I am the only one actually creating notebooks but I would like to make some notebooks visible to other team members in a read-only way. Ideally I could just share a URL with them that they would bookmark for when they want to see the notebook with refreshed data.

I saw export options but cannot find any mention of "publishing" or "making public" local live notebooks. Is this impossible? Is it maybe just a wrong way to think about how Jupyter should be used?

TylerH
  • 20,799
  • 66
  • 75
  • 101
xav
  • 4,101
  • 5
  • 26
  • 32
  • 6
    It looks like you can just put the `.ipynb` files on GitHub: http://blog.jupyter.org/2015/05/07/rendering-notebooks-on-github/ – jonrsharpe Aug 06 '15 at 12:47
  • 4
    But to keep it private, we would have to pay for accounts. – xav Aug 06 '15 at 13:52
  • So you don't want them to be wholly public? If only to locals, why can't they access the server? – jonrsharpe Aug 06 '15 at 13:55
  • 2
    Sorry if it was not clear. I would like to serve the notebooks on the server (only the team can see it) but if possible I would like to avoid giving them the password of the Jupyter instance or any other way of access with edit rights. – xav Aug 06 '15 at 15:08
  • 4
    maybe you can simply create a secret gist (https://gist.github.com/) "Secret gists are hidden from search engines but visible to anyone you give the URL." one even doesn't have a github account. fast. – tagoma Sep 18 '16 at 09:22
  • We faced this problem too, so we created Jovian: https://www.jovian.ml . All you need to do is import a Python library ( import jovian ), and run the command ( jovian.commit() ) inside the Jupyter notebook, and you'll get a publicly shareable link to the notebook. Example: https://www.jovian.ml/aakashns/jovian-tutorial . – aakashns Nov 01 '19 at 20:43
  • Easiest way is to make `.ipynb` files into read-only mode with `chmod a-w` on the server, then share the tokenized URL of the notebook. They will still be editable but changes won't be saved. For convenience you can run a readonly notebook on a different port than your work notebook (with different `.ipynb` files, of course). – Skippy le Grand Gourou Jan 13 '20 at 21:08

6 Answers6

84

The "best" way to share a Jupyter notebook is to simply to place it on GitHub (and view it directly) or some other public link and use the Jupyter Notebook Viewer. When privacy is more of an issue then there are alternatives but it's certainly more complex; there's no built-in way to do this in Jupyter alone, but a couple of options are:

Host your own nbviewer

GitHub and the Jupyter Notebook Veiwer both use the same tool to render .ipynb files into static HTML, this tool is nbviewer.

The installation instructions are more complex than I'm willing to go into here but if your company/team has a shared server that doesn't require password access then you could host the nbviewer on that server and direct it to load from your credentialed server. This will probably require some more advanced configuration than you're going to find in the docs.

Set up a deployment script

If you don't necessarily need live updating HTML then you could set up a script on your credentialed server that will simply use Jupyter's built-in export options to create the static HTML files and then send those to a more publicly accessible server.

cmaher
  • 5,100
  • 1
  • 22
  • 34
Michael Leonard
  • 1,693
  • 20
  • 18
  • You can also access nbviewer directly on https://nbviewer.jupyter.org/ and add there your file – guhur Oct 29 '16 at 16:22
  • The [Jupyter Notebook Viewer](https://nbviewer.jupyter.org/) will render static notebooks within gists too, sparing you from needing a full-fledged GitHub repo. – Wayne Nov 29 '17 at 18:28
  • Note "add there your file" does not include _uploading_ it with a web dialog allowing you to pick the file locally from the browser file system. – lucid_dreamer Mar 03 '18 at 00:11
36

Google has recently made public its internal Collaboratory project (link here). You can start a notebook in the same way as starting a Google Sheet or Google Doc, and then simply share the notebook or add collaborators..

For now, this is the easiest way for me.

Mapl
  • 517
  • 4
  • 10
  • 2
    I was surprised to find how intuitive and easy Colaboratory was to use. Note that you can share the link as view only but visitors can enable "playground" mode to run code blocks and adjust parameters. very cool. – Timothy Lombard Feb 15 '18 at 02:32
  • The shortcuts are all broken in colab. – mathtick Aug 08 '19 at 20:42
  • You can start here: [Google colab introduction](https://colab.research.google.com/notebooks/intro.ipynb) – cglacet Apr 02 '20 at 08:36
26

Michael's suggestion of running your own nbviewer instance is a good one I used in the past with an Enterprise Github server.

Another lightweight alternative is to have a cell at the end of your notebook that does a shell call to nbconvert so that it's automatically refreshed after running the whole thing:

!ipython nbconvert <notebook name>.ipynb --to html

EDIT: With Jupyter/IPython's Big Split, you'll probably want to change this to !jupyter nbconvert <notebook name>.ipynb --to html now.

Randy
  • 14,349
  • 2
  • 36
  • 42
13

It depends on what you are intending to do with your Notebook: do you want that the user can recompute the results or just playing with them?

Static notebook

NBViewer is a great tool. You can directly use it inside Jupyter. Github has also a render, so you can directly link your file (such as https://github.com/my-name/my-repo/blob/master/mynotebook.ipynb)

Alive notebook

If you want your user to be able to recompute some parts, you can also use MyBinder. It takes some time to start your notebook, but the result is worth it.

As said by @Mapl, Google can host your notebook with Colab. A nice feature is to compute your cells over a GPU.

guhur
  • 2,500
  • 1
  • 23
  • 33
  • 1
    [MyBinder](https://mybinder.org/) will make a badge that you can place in your repo for users to easily launch an **active** (**live**) notebook, see [here](https://github.com/binder-examples/requirements), for a basic example. You can even specify to launch directly into a certain **ACTIVE** notebook page and not the Jupyter dashboard by entering a path to a notebook file before you press the arrow down next to the launch button to get your badge. – Wayne Nov 29 '17 at 19:17
7

A great way of doing this on WordPress consists of the following steps:

Step 1: Open your Jupyter notebook in a text editor and copy the content which may look like so: Your .ipynb file may look like this when opened in a text editor

Step 2: Ctrl + A and Ctrl + C this content. Then Ctrl + V this to a GitHub Gist that you should create.

Step 3: Create a public gist and embed the gist like you always embed gists on WordPress, viz., go to the HTML editor and add like so:

[gist gist_url]

I have actually implemented this on my blog. You can find the post here

Anirudh
  • 121
  • 1
  • 8
5

One more way to achieve this goal would be using JupyterHub.

With JupyterHub you can create a multi-user Hub which spawns, manages, and proxies multiple instances of the single-user Jupyter notebook server. Due to its flexibility and customization options, JupyterHub can be used to serve notebooks to a class of students, a corporate data science group, or a scientific research group.

enter image description here

Denis Rasulev
  • 3,744
  • 4
  • 33
  • 47
  • 2
    So far jupyterhub is only useful for giving many users access to use jupyter. The sharing of notebooks is being worked on with ShareHub, but jupyterhub doesn't help. – Craig May 31 '17 at 16:10
  • @Craig, did you have a chance to try it? What's ShareHub? What made you think that JupyterHub doesn't help in this case? Can you, pls, support your comment with any arguments so others could learn from it? – Denis Rasulev Jun 01 '17 at 10:41
  • @Craig I second "Denis Rasulev"'s request. ShareHub doesn't return any meaningful results, and the rest of your comment is cryptic. – lucid_dreamer Jun 05 '17 at 15:17
  • @Denis how does this solution compare to http://mybinder.org/ ? Any comments? – lucid_dreamer Jun 05 '17 at 15:17
  • @user1712447, idea looks great but I had no luck with examples getting "no space" error all the time. So can't tell you anything. Beside, discussing it here, imho, looks a bit like off topic. – Denis Rasulev Jun 05 '17 at 16:32
  • @DenisRasulev, Sorry I meant hubshare: https://github.com/jupyterhub/hubshare Jupyterhub by itself just serves independent notebook environments, but you still can't share the same set of notebooks. See https://github.com/jupyterhub/jupyterhub/issues/394 – Craig Jun 05 '17 at 22:46