Installing JupyterLab (all platforms)#

This chapter contains the instructions about how to install additional useful tools which will enhance your python installation a great deal!

Note

Installing JupyterLab and the python packages need to be done only once on the computer you are using! If you are using a workstation in a lab, you will have to do it again if you change for another workstation or if the workstation is reset.

Prerequisites#

We assume that the python installation instructions have worked for you (or that you are using a university workstation), and that you:

  • are able to start one of anaconda or miniforge prompt (depending on whether you are using anaconda or miniforge)

  • can type one of mamba list or conda list successfully

  • can type python and open a python interpreter.

For a primer on the different prompts and interpreters, see my beginners’ programming class notes

Installation instructions#

Open a miniforge/anaconda prompt (or a terminal on Linux/macOS) and type:

conda create --name qcr --channel conda-forge jupyterlab jupyterlab-myst numpy scipy pandas matplotlib xarray netcdf4 cartopy cftime geopandas seaborn rioxarray rasterio cf_xarray dask regionmask
mamba create --name qcr --channel conda-forge jupyterlab jupyterlab-myst numpy scipy pandas matplotlib xarray netcdf4 cartopy cftime geopandas seaborn rioxarray rasterio cf_xarray dask regionmask

This will install jupyter-lab and all the packages at the same time. Say “yes” to the install question.

Note

One package used later in the class, spei (Workshop 05, droughts), is not available on conda-forge. Install it with pip once the environment above is created and activated:

conda activate qcr
pip install spei

The drought lesson reminds you about this when the package is first needed.

To check if it worked, type ipython in the terminal, which should display something like:

Python 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:15:42) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.1.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]:

The only visual difference between the ipython and python interpreters is that >>> has been replaced by In [1]:. More on this in class if you are interested.

Exit ipython (remember how? Use exit()) and move on to the next step.

Opening JupyterLab in the qcr environment and folder#

Note

This needs to be done every time you want to work on your notebooks!

From now on, and regardless of the computer you are using, you will have to activate the qcr environment before starting jupyter-lab. I strongly recommend to start jupyter-lab from the folder where you want to work (i.e. where you have saved your notebooks and data).

The steps are as follows:

  1. Open a miniforge prompt (or a terminal on Linux/macOS)

  2. Navigate to the folder where you want to work by typing:

    cd C:\path\to\folder
    

    I recommend copying the path from the file explorer - see video below for an example.

  3. Activate the qcr environment by typing:

    conda activate qcr
    
  4. Start jupyter-lab by typing:

    jupyter-lab
    

This is best explained with a simple video:

If you are new to JupyterLab, you can watch this video on my beginners class.

Learning checklist#