Jupyter Notebook/Lab #
Everything here is inside a running Python environment.
Basics #
Convert to HTML:
$ jupyter nbconvert --execute --to html my_notebook.ipynb
Debug #
Rebuild lab:
# takes 1.5 min on my machine:
jupyter lab build
Custom CSS for Lab #
For usage see: Browser extension #Customise the web
Range: URLs starting with: http://localhost:8888/lab
/* my file names are too long */
/* whole file name */
.jp-DirListing-item {
padding: 4px;
}
/* kernel running indicator */
.jp-DirListing-item.jp-mod-running .jp-DirListing-itemIcon::before {
left: -5px;
}
/* file icon */
.jp-DirListing-itemIcon {
flex: 0 0 16px;
}
/* file name text */
.jp-DirListing-itemText {
text-overflow: clip;
}
/* date modified */
.jp-DirListing-itemModified {
flex: 0 0 95px;
}
Settings #
Refs:
- jupyterlab/packages/codemirror/src/extension.ts at main · jupyterlab/jupyterlab
- Advanced Usage — JupyterLab 4.0.6 documentation
Find paths #
# All paths (same): (some of them may not exit.)
jupyter --path
jupyter --paths
# config:
# /Users/loikein/.jupyter
# /Users/loikein/.local/etc/jupyter
# /usr/local/Caskroom/miniconda/base/envs/google-maps/etc/jupyter
# /usr/local/etc/jupyter
# /etc/jupyter
# data:
# /Users/loikein/Library/Jupyter
# /Users/loikein/.local/share/jupyter
# /usr/local/Caskroom/miniconda/base/envs/google-maps/share/jupyter
# /usr/local/share/jupyter
# /usr/share/jupyter
# runtime:
# /Users/loikein/Library/Jupyter/runtime
# Only lab paths:
jupyter lab path
# Application directory: /usr/local/Caskroom/miniconda/base/envs/google-maps/share/jupyter/lab
# User Settings directory: /Users/loikein/.jupyter/lab/user-settings
# Workspaces directory: /Users/loikein/.jupyter/lab/workspaces
Generate top level config file: (credit)
jupyter lab --generate-config
# Writing default config to: /Users/loikein/.jupyter/jupyter_lab_config.py
page_config.json
(user-level) (deprecated) #
This config method is deprecated.
Doc: Advanced Usage — JupyterLab 4.0.6 documentation #page_config.json (deprecated)
Credit: jupyterlab/jupyterlab Issue #9240
jupyter labextension disable @jupyterlab/launcher-extension
jupyter labextension enable @jupyterlab/launcher-extension
Then I got: /usr/local/Caskroom/miniconda/base/envs/google-maps/etc/jupyter/labconfig/page_config.json
with the following content:
{
"disabledExtensions": {
"@jupyterlab/launcher-extension": false
}
}
overrides.json
(environment-level) #
You can override default values of the extension settings by defining new default values in an
overrides.json
file. For example, if you would like to override the default theme to be the dark theme, create anoverrides.json
file containing the following lines in the application settings directory (for example, if the JupyterLab Application Directory is<sys.prefix>/local/share/jupyter/lab
, create this file at<sys.prefix>/local/share/jupyter/lab/settings/overrides.json
).{ "@jupyterlab/apputils-extension:themes": { "theme": "JupyterLab Dark" } }
~ Advanced Usage — JupyterLab 4.0.6 documentation #overrides.json
jupyterlab-settings
(user-level) #
The user settings directory contains the user-level settings for Jupyter extensions.
By default, the location is
$HOME/.jupyter/lab/user-settings/
, where$HOME
is the user’s home directory. This folder is not in the JupyterLab application directory because these settings are typically shared across Python environments. The location can be modified using theJUPYTERLAB_SETTINGS_DIR
environment variable.JSON5 files are automatically created in this folder recording the settings changes a user makes in the JupyterLab Advanced Settings Editor. The file names follow the pattern of
<extension_name>/<plugin_name>.jupyterlab-settings
. These values override the default values given by extensions, as well as the default overrides from the overrides.json file in the application’s settings directory.~ Advanced Usage — JupyterLab 4.0.6 documentation #JupyterLab User Settings Directory
Useful Notebook Extensions #
Doc: Extensions — JupyterLab 4.0.6 documentation
jupyter labextension list
# JupyterLab v4.0.5
# /usr/local/Caskroom/miniconda/base/envs/google-maps/share/jupyter/labextensions
# jupyterlab-jupytext v1.3.9 enabled X (python, jupytext)
# jupyterlab_pygments v0.2.2 enabled X (python, jupyterlab_pygments)
# jupyterlab-execute-time v3.0.1 enabled OK (python, jupyterlab_execute_time)