Jupyter Notebook/Lab #
Warning: This post hasn't been updated for over a year. The information may be out of date.
Everything here is inside a running Python environment.
Basics #
Convert to HTML:
$ jupyter nbconvert --execute --to html my_notebook.ipynbDebug #
Rebuild lab:
# takes 1.5 min on my machine:
jupyter lab buildCustom 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;
}
/* no upper case file title */
.jp-SidePanel-header {
text-transform: none;
}
/* monospace toc */
.jp-TableOfContents-tree {
font-family: monospace;
}
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/workspacesGenerate top level config file: (credit)
jupyter lab --generate-config
# Writing default config to: /Users/loikein/.jupyter/jupyter_lab_config.pypage_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-extensionThen 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.jsonfile. For example, if you would like to override the default theme to be the dark theme, create anoverrides.jsonfile 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$HOMEis 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_DIRenvironment 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.1.1
# /usr/local/Caskroom/miniconda/base/envs/myenv/share/jupyter/labextensions
# jupyterlab-jupytext v1.4.2 enabled OK (python, jupytext)
# jupyterlab_pygments v0.2.2 enabled X (python, jupyterlab_pygments)
# jupyterlab-execute-time v3.1.1 enabled OK (python, jupyterlab_execute_time)
# jupyterlab-indent-guides v0.1.0 enabled OK (python, jupyterlab-indent-guides)