Skip to main content

Developing and executing Jupyter notebooks

Jupyter notebooks provide an interactive environment for developing and sharing code in Python, R, Julia, and several other languages. We provide notebooks demonstrating software tools and packages in each software blueprint. Workstations can also be used to develop and share new notebooks. There are three options for executing and developing notebooks on a workstation.

JupyterLab

The web-based JupyterLab interface is available in all software blueprints and provides an interactive development experience for Jupyter notebooks. Simply open a notebook from the file browser sidebar. See the JupyterLab documentation for additional information.

VS Code Server

The web-based VS Code development environment is available in all software blueprints. The "Jupyter" and "Python" extensions are installed by default, and Jupyter notebooks can be opened using the file browser sidebar. If you are asked to pick a kernel upon executing a notebook, the default python kernel is in a conda environment called base. R and Julia kernels are also available with the blueprints that support these languages.

VS Code Desktop

After connecting to a workstation with VS Code over SSH, you can execute and develop Jupyter notebooks right in the IDE. First, you must install extensions for Jupyter and Python support.

  1. Open the "Extensions" menu on the sidebar.
  2. For each of these extensions, paste the text in the search bar, select the first result, and click the "Install" button.
    • ms-toolsai.jupyter
    • ms-python.python

You can configure VS Code Desktop to automatically install these extensions any time you connect to a remote machine.

  1. Open the "Settings" interface in VS Code by clicking the gear icon in the bottom left of the window.
  2. Search for "ssh default extensions".
  3. In the menu for "Remote.SSH: Default Extensions", select "Add Item".
  4. Add the following extensions to the list:
    • ms-toolsai.jupyter
    • ms-python.python

Alternatively, you can open the settings.json file for your VS Code installation and add the following section:

Add to VS Code settings.json
"remote.SSH.defaultExtensions": [
"ms-toolsai.jupyter",
"ms-python.python"
]

Adding new kernels to JupyterLab and VS Code

Creating isolated conda environments for each programming project is a good way to avoid conflicts between dependencies. To use new conda environments in JupyterLab and VS Code, follow these steps:

  1. Install the appropriate IPython kernel package into the new conda environment. Depending on the programming language you want to use, the packages are listed below.

    • Python: ipykernel
    • R: IRkernel
    • Julia: Add the IJulia package from the Julia REPL. First start Julia from a terminal, then type using Pgk; Pkg.add("IJulia").

    As an example, this command creates a new conda environment with Python ready for use in JupyterLab:

    Add a new conda environment ready for use in Jupyter
    mamba create --name new_env --channel bioconda ipykernel biopython
  2. Within JupyterLab and VS Code, select the new kernel. There are boxes at the top-right corner of the JupyterLab and VS Code UIs that allow you to select a kernel. The new environment may take a few seconds to appear in the select box.