Software

Using Jupyter Lab for Python Projects

I was looking into using Jupiter Notebooks for a project when I found the JupyterLab software, it is a tool that looks to combine your workflow into a single place. This allows you to open, and interact with, Jupyter Notebooks, text editors, terminals, and many others.

You can download it for your system from the Jupyter website. The full documentation, as well as many intro videos, can be found on JupyterLab Docs.

The way JupyterLab works is that it creates a web server on your local machine that allows you to open a web browser to the JupyterLab interface. To start the server on Mac OS or Linux type the following command into the native terminal and hit enter.

jupyter-lab

This will set up the environment and automatically open a browser tab to the lab interface that will look like the image below.

From the Launcher tab, you can do all kinds of amazing things, but most importantly it allows you to create new Jupyter Notebooks.

Features

The main features of the Jupyter Lab and Jupyter notebooks are the ability to work in segmented code areas and view inline graphs. This allows you to quickly iterate a design modifying and re-running only the blocks of code that you are working on.

The launcher also allows you to bring up a convenient terminal interface. My ZSH terminal on Mac uses the Powerlevel10k so I was able to include the required fonts. The terminal can be used just like any other terminal, mainly I use this for running python scripts that are not Jupyter Notebooks.

The other nice tool in the lab software is the markdown visualization options. This is super useful for creating README documentation as you can open them in normal mode for editing and open the preview at the same time!

If you need to send a Jupyter Notebook to someone that does not have Jupyter Lab, there are built-in export options for a variety of formats. You may need some python libraries to enable all of the options.

Embed Jupyter Notebooks in WordPress

I like to share my work on this blog but some of my previous attempts to embed the Jupyter Notebooks in WordPress have ended in frustration.

The easiest method so far is with GitHub gists, but it requires GitHub as a host and does not work directly from a repo. This means it is a separate file you need to track if you make changes.

All you need to do is create a gist on GitHub by going navigating to the link below, add your code, and hit the create gist button. make sure to set it ad public if you want it to be discoverable.

https://gist.github.com/

You can then just copy the resulting URL from your browser and paste it directly into your WordPress blog.

Below is an example of a gist that I used for a previous blog post using Matplotlib and NumPy to plot some cool FFT visualizations.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Conclusion

Safe to say I will using Jupyter Lab for many more projects! it’s amazing how much you can get done when you have the right tools available. The Jupyter Notebooks have definitely allowed me to speed through algorithm development and testing.