Skip to content

Every day work with JupyterLab

Abby Drury edited this page Jan 12, 2023 · 4 revisions

You'll need some special commands in order to actually use the JupyterLab in Docker.

These commands assume that you:

Stop and start JupyterLab

Instructions on stopping and starting JupyterLab can be found here.

View the Docker container logs

  1. To view the Docker container logs, at the command line:

    docker logs -f CONTAINER_NAME

    If you have trouble with this command, double check your container name.

  2. You can exit the logs using the key command control+c (also sometimes written as ^C).

Add packages and extensions

Python package requirements

  1. In environment/requirements.txt, add the package and version. This is a classic requirements.txt:
    packageName==packageVersion
  2. Install packages and extensions.

R package requirements

  1. Find the package on cran.r-project.org (eg: https://cran.r-project.org/package=XML)
  2. Find the appropriate version of the package, either in the "Package source" link or on the "Old sources" archive page.
  3. In environments/r-packages.R add the package name and version on a new line:
    if (! require("XML") || packageVersion("XML") != "3.99.0.3") { install_version("XML", version="3.99.0.3") }
    This checks whether the package is already installed and at the proper version, and installs it if it is missing or at the wrong version.
  4. Install packages and extensions.

HINT: If the most recent version of the package won't install, you can figure out the most recent compatible version by running packages.install("package-name") in an R notebook in JupyterLab, then running packageVersion("package-name"). Then, be sure to find that version on cran.r-project.org and add that version of the package to environments/r-packages.R.

JupyterLab extensions

  1. Find the extension and version that you want.
  2. Add the extension name and version to environment/jupyter-extensions.txt as a new line.
    1. If the extension can be installed successfully via pip, use the following syntax:
      ipympl,0.9.2
      
    2. If the extension cannot be installed using pip or otherwise must be installed using jupyter labextension install, use the following syntax:
      jupyterlab-spreadsheet,0.4.1,manual
      
  3. Install packages and extensions.

Install packages and extensions

You need to rebuild the container in order for package changes to take effect.