changed 6 years ago
Linked with GitHub

JupyterLab Doc

Installation

Install JupyterLab

  1. Probably the easiest way is to use conda (note that you can also use Miniconda which would a smaller installation if you don't want to have the entire Anaconda)
  2. Create a conda environment for sage: conda create -n sage (note: your folder will be called sage. you can also name this folder something else other than sage)
  3. Install JupyterLab: conda install -c conda-forge jupyterlab=1.0.1

Now you can start JupyterLab using the command jupyter lab on the terminal while in your sage environment.

Install Sagemath kernel

  1. In a command window, run the command
    jupyter kernelspec install /path/to/sage/local/share/jupyter/kernels/sagemath --user
    (if you have multiple Sagemath installations, you can do /path/to/sage/local/share/jupyter/kernels/sagemath/ --user --name ChosenName)

  2. To link Jupyterlab to Sage, first open the file kernel.json which may be located in Library/Jupyter/kernels/sagemath/kernel.json or in a different path. To look up the path, first look up the available kernels.

    • To check the available kernels, type jupyter kernelspec list or sage kernelspec list (I am not sure which one is correct - someone please edit this line)
    • Add
      "env":{"SAGE_ROOT":"/path/to/sage"}
      at the end of the dictionary in the file kernel.json.

To make Jupyterlab an app in Chrome:

  1. If this is your first time modifying Jupiter Notebook configuration, generate it by typing in a command window:
    jupyter lab --generate-config
  2. Edit the file
    ~/.jupyter/jupyter_notebook_config.py
    and add the line
    c.LabApp.browser = ‘/path/to/Google Chrome/ —-app=%s’
    For example, on a Mac, add the line
    c.LabApp.browser = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --app=%s’

Activating and deactivating the Conda environment (I am not sure whether this is the proper term - please edit)

  1. To activate Jupyter Lab, go to the terminal and type conda activate [Name of your conda environment, which is this example is Sage]
  2. Once the environment is activated, type jupyter lab on the terminal. This should open a browser (your default browser) running JupyterLab.
  3. To deactivate, type conda deactivate

Keyboard shortcuts that may be useful

We want to (re)define some keyboard shortcuts

  • Activate the next tab: Ctrl+PageDown
  • Activate the previous tab: Ctrl+PageUp
  • Set syntax highlighting for current editor: Ctrl+P
  • New Console for noteook / texteditor: Alt+B

In JupyterLab open the Advanced Settings Editor (Settings -> Advanced Settings Editor) and open Keyboard Shortcuts.
Copy and paste the following to the editor and save. This code works for Jupyterlab >= 1.0.0

{
    "shortcuts": [
        {
            "command": "application:activate-next-tab",
            "keys": [
                "Ctrl PageDown"
            ],
            "selector": "body"
        },
        {
            "command": "application:activate-previous-tab",
            "keys": [
                "Ctrl PageUp"
            ],
            "selector": "body"
        },
        {
            "command": "codemirror:change-mode",
            "keys": ["Accel P"],
            "args": { "name": "Python" },
            "selector": ".jp-FileEditor"
        },
       
        {
            "command": "filemenu:create-console",
            "keys": ["Alt B"],
            "selector": ".jp-FileEditor"
        },
    ]
}

Problems

  • view(...) "freezes cell"
  • attach(*files) does not work

Other usefull stuff

Select a repo