Is it possible to open a Jupyter notebook from a remote URL?

Not sure if has been discussed elsewhere previously (couln’t find from a quick search here), but I was wondering if it would be possible to open a Jupyter notebook from a remote URL (e.g. within Binder?

If not, is there any other online service/tool which could help do this?

Certainly, since that remote URL is public and doesn’t require FTP for retrieval.

Launch JupyterLab by clicking this. (The source of that is the JupyterLab + Binder example repo.)

When the session launches, make a new cell in the notebook that opens by default, and then in that new cell paste the following code:

!curl -OL
%pip install brian2
%pip install matplotlib

Run that cell.

After that is done running, you should see the obtained file demo_notebook.ipynb listed in the file navigation panel on the left.
Double-click that file name and you can now run the cells in the notebook. A few cells are set up to purposefully trigger errors, and so you cannot just Run all.

By the way, if the other notebook was in a Github repository, you could use nbgitpuller to construct a link to both launch the environment backing the session and retrieve the notebook in another repo into the launched Jupyter session. You can go here to get a form for generating such links. The environment would already need to have brian2 and matplotlib modules installed.

The instructions in the top part will cover you if you wanted to only do this once for your own use.
If you want to do this in a way you could share with others, plus have the other notebooks in the series as alluded to at the bottom of that one to which you linked, you’d need to make your own archive, for example, a Github repo, where you put a requirements.txt file to install the brian2 and matplotlib by listing them, see requirements.txt example here.
As for handling retrieving the notebooks, you’d make a postBuild file that handles that step. After you build the image once by launching MyBinder pointed at your repo, it will have the notebooks ‘baked’ into the image that MyBinder will use even though they are not part of the repository you’ll launch. Constructing a working postBuild can be tricky because I find you cannot just use the Github browser-based editor to do that. In my experience, you need to run git locally and push a commit to the repo so that the permissions of the postBuild allow executing the commands in it. The JupyterLab example repo I referenced above has an example postBuild file in it. (If you list all the notebook URLs here, I’d be happy to help set it up and you can fork it from my Github repo and continue to develop from that.)
Alternatively, you could use a start file to handle the step of getting the notebooks; however, that would run the step at the time of actual start-up of each individual triggered Jupyter session, and so it would add some launch time as those are fetched. This is not ideal concerning making launch time as fast as ppossible. Depending on how big or how many notebooks were being fetched, the additional time may or may not be significant. However, you may still wish to put the retrieval step in the start configuration file if you are indeed going to be developing the notebook content further with it often changing. This is valid so that you won’t have to remember to trigger a build on the repo that is pulling the remote content everytime you change the notebook content that is sourced remotely. If the retrieval step is in the start file, it will always pull the latest version. This is a valid compromise that may extend the launch time of the session some while insuring the content is the latest.

See about postBuild and start here.


Let me start with a BIG thanks for the detailed reply you have posted above! It is really helpful. I have been a very basic user of Binder in the past and certainly wasn’t aware of all these possibilities.

I think it might help if I elaborate a bit further on my particular use case:

  • we are developing a tool that would allow users to make available various resources, including Jupyter notebooks that demonstrate their work
  • as per policy we are required to store all these files in our central repo (“…”) that is based on OpenStack Swift storage, and so I don’t have the option of using a GitHub repo or similar
  • the files are unlikely to change over time, but new files will continuously be added, with each notebook getting its own URL
  • we would like to allow launching these notebooks in a Jupyter ennvironment when the user clicks on a link on a web page. The web-pages themselves are auto generated with the resource files being fed as input.
  • for other functionalitites (not related to Jupyter) we generally access services via APIs such as, for example, “

Can I do something like this with binder, or any other cloud based Jupyter service?

Thanks again @fomightez for taking time out and responding to this post.

It sounds like you’d want to run your own Binderhub.