How can I change code colors in Jupyter-lab installed via pip?

How can I change the colors of code instructions in Jupyterlab installed via pip? For Anaconda I do it through the index.css file but for Jupyterlab installed via pip I don’t know how to customize the code colors. For example, changing the green color of “import” to purple and some others.

LB51u

the default themes rest @ ~/.local/share/jupyter/lab/themes if installed at user level.
otherwise it should be in /usr/share/....

the colors are defined in the index.css files, and syntax colors are in this block :

/* Code mirror specific styles */

  --jp-mirror-editor-keyword-color: #008000;
  --jp-mirror-editor-atom-color: #88f;
  --jp-mirror-editor-number-color: #080;
  --jp-mirror-editor-def-color: #00f;
  --jp-mirror-editor-variable-color: var(--md-grey-900);
  --jp-mirror-editor-variable-2-color: rgb(0, 54, 109);
  --jp-mirror-editor-variable-3-color: #085;
  --jp-mirror-editor-punctuation-color: #05a;
  --jp-mirror-editor-property-color: #05a;
  --jp-mirror-editor-operator-color: #a2f;
  --jp-mirror-editor-comment-color: #408080;
  --jp-mirror-editor-string-color: #ba2121;
  --jp-mirror-editor-string-2-color: #708;
  --jp-mirror-editor-meta-color: #a2f;
  --jp-mirror-editor-qualifier-color: #555;
  --jp-mirror-editor-builtin-color: #008000;
  --jp-mirror-editor-bracket-color: #997;
  --jp-mirror-editor-tag-color: #170;
  --jp-mirror-editor-attribute-color: #00c;
  --jp-mirror-editor-header-color: blue;
  --jp-mirror-editor-quote-color: #090;
  --jp-mirror-editor-link-color: #00c;
  --jp-mirror-editor-error-color: #f00;
  --jp-mirror-editor-hr-color: #999;

import is a keyword so you’d have to change the first variable.

2 Likes

Cross-posted here on StackOverflow.

1 Like

I mean when Jupyter is installed via PIP, these folder theme and the index.css file do not exist, only when installing via Anaconda.

i have never used anaconda and installed jupyterlab via pip and i do have these folders. are you on windows, mac or linux?

edit: run jupyter --paths and check directories under data.

2 Likes

Thank you so much. You saved the day… success !!

I found on the path: @~/AppData/Local/Programs/Python/Python311/share/jupyter/lab/themes

2 Likes