Jupyter

Jupyter is a web based interactive computing platform. The primary tool, a notebook (.ipynb files), is like a notebook for code, with markdown cells for commentary, multiple different languages supported, and easy kernel switching. Jupyter Lab is a great place to build and edit the notebooks, and is a great place to build and learn from code because of each cell having its own separate executable block.

How Can I Upload Code to Anvil in Jupyter Notebook?

After you’ve downloaded the project, log in to Anvil and request a Jupyter Lab session, and upload the file. You’ll see the upload button like the one below in the top left corner of your screen.

upload to anvil

Problems With Jupyter Loading

Computers do exactly what we tell them to do. The trouble is we have to figure out what we told them to do.
— Ancient Programming Wisdom

Sometimes we ask Jupyter to do something that causes problems, and we aren’t even sure exactly where the problem is in the stack. Here’s how you can stop the runaway kernel on Jupyter.

On the top left corner of Jupyter Lab, click the round circle with a square in it.

show running kernels

Now you’ll see all the tabs opened and the kernels running. You can hover and click one at a time to shut them down, or you can 'Shut Down All'.

shut down kernel

I Want To Steal All The Code From The Notebook, Without The Data Mine’s Comments

While it is possible to Download and Save As…​ Python in the Jupyter Lab top left menu for some files, it doesn’t always work. The code below will remove the Markdown and other cells, but keep the Python code, including any #hashtag comments in Python. This isn’t very easy to do on Anvil, but if you download the file, then get the path of the notebook, this will export the Python cells to a .py script in the same folder. Make sure you have Jupyter installed locally to do this.

Replace the /path/to/notebook with the path to the notebook you want to convert.
There is similar functionality to convert to other languages that Jupyter supports.
This is a shell script.
jupyter nbconvert --to python /path/to/notebook.ipynb

These Notebooks Are Long, and Hard To Read Through

The table of contents section can help jump quickly in Notebooks that are particularly big. Try clicking the 3 lines along the upper left corner of Jupyter Lab:

jupyter table of contents