pythonjupyter-notebookjupyteripythonjupyter-console

IPython --profile option works with `jupyter console` but not JupyterLab


I have the following (redacted) my-project/kernel.json in one of the standard Jupyter kernel paths:

{
  "argv": [
    ".../my-project/.local/conda/bin/python",
    "-Xfrozen_modules=off",
    "-m",
    "ipykernel_launcher",
    "--ipython-dir",
    ".../my-project/.local/ipython",
    "--profile",
    "default",
    "-f",
    "{connection_file}"
  ],
  "display_name": "My Project",
  "language": "python",
  "metadata": {
    "debugger": true
  }
}

In the .local/ipython/profile_default/ipython_config.py and .local/ipython/profile_default/startup/*.py scripts, I have some custom configuration, such as adding entries to sys.path and enabling the autoreload extension.

When I run jupyter console --kernel my-project, all of the customization seems to work perfectly.

However when I run a JupyterLab notebook using the exact same kernel, none of the customizations seem to work!

What might cause this problem? Is there an effective way to debug this? Some log file to inspect? A cache to clear? Some known "gotcha" setting to be aware of?


Solution

  • Yup, just caching! Apparently JupyterLab is caching the kernelspec. I just had to restart the Jupyter server, and the new kernel setting was applied.

    Normally I would close this as "not reproducible" but this might be useful for someone else in the future.