# Tip: Interactive Python Notebooks With Binder

> Display your public GitHub repositories in an interactive notebook.

- Canonical: https://dennisokeeffe.com/blog/2021-07-28-interactive-python-notebooks-with-binder
- Published: 2021-07-28
- Updated: 2021-07-28
- Tags: beginner, python, 100daysofpython, jupyternotebooks

> This is Day 9 of the #100DaysOfPython challenge.

This is an overview of how to display your public GitHub repositories containing notebook files in an online interactive notebook using [Binder](https://mybinder.org/) and [Jupyter](https://jupyter.org/).

## Prerequisites

1. Familiarity with [Pipenv](https://pipenv.pypa.io/en/latest/). See [here](https://blog.dennisokeeffe.com/blog/2020-07-04-abcs-of-pipenv) for my post on Pipenv.
2. Familiarity with [JupyterLab](https://jupyterlab.readthedocs.io/en/stable/gettingstarted/install.html).
3. A basic JupyterLab setup. See my "Hello Jupyter Notebook" post [here](https://blog.dennisokeeffe.com/blog/2021-07-19-hello-jupyter-notebook) for my post on JupyterLab.
4. A GitHub account.
5. A public GitHub repository containing notebook files.

## Getting started

We are simply going to publish any Jupyter notebook with a `.ipynb` extension in our public GitHub repository to Binder.

If you need an example repo, you can use my [hello-jupyterlab repo](https://github.com/okeeffed/hello-jupyter-lab).

[Binder](https://mybinder.org/) itself is simply a website that enables you to display your public GitHub repositories in an interactive notebook.

You can add your own public repo or add the link for my example `https://github.com/okeeffed/hello-jupyter-lab`.

Add the URL into the `Build and launch a repository` input and click `Launch`.

## Exploring the notebook

Once the notebook has loaded (and assuming you are using my repo as an example), you can navigate to an example doc in `docs/1_hello_requests.ipynb`,

Once there, you can click on the `Run` button to execute the code and see the output.

We can go one step further by also adding more cells to print the responses:

![Requests in action](https://cdn.dennisokeeffe.com/assets/2021-07-28-interactive-python-notebooks-with-binder/1-binder-requests.png)

## Adding dependencies

Binder itself does a lot of the heavy lifting for you and supports a wide range of [configuration files](https://mybinder.readthedocs.io/en/latest/using/config_files.html) that you would use as part of dependency management.

In the case of the example, the `Pipfile.lock` is automatically identified and the dependencies were installed.

## Resources and further reading

1. [Binder](https://mybinder.org/)
2. [Hello, JupyterLab](https://blog.dennisokeeffe.com/blog/2021-07-19-hello-jupyter-notebook)
3. [Pipenv](https://pipenv.pypa.io/en/latest/)
4. [Binder configuration files](https://mybinder.readthedocs.io/en/latest/using/config_files.html)

_Photo credit: [juvnsky](https://unsplash.com/@juvnsky)_
