Search code examples
node.jsjupyter-lab

Variable inspector of Jupyter Lab is blank


I am using a JupyterLab notebook for my project. The problem is that the variable inspector on the right sidebar does not show anything even after running my notebook. Do I need to change some settings to enable it?

enter image description here

Edit

The variable inspector does not work probably because I haven't installed the Jupyter extension, debugger. However, when I tried to install it, I got an error message, "Please install Node.js > 12.0.0" .

I think I need to install the node.js directly to the system (cent OS 7) rather than my conda environment so that JupyterLab can recognize it, but I'm not sure how. Which folder should I need to install it? How do I set the environment variable?


Solution

  • The variable list is part of debugger which is part of JupyterLab. Since JupyterLab 3 it does not require installation, but it does require a kernel which supports debugging. Modern versions of ipykernel (roughly > 6.0) and xeus-python kernel are examples of kernels supporting debugging. First you need to ensure that you have a recent versions of a kernel supporting debugging.

    If you use a custom kernel spec (which is seen on your screenshot based on the name of the kernel - "My env _pytorch3d Kernel" is not a standard kernel specification) you need to ensure that your kernelspec advertises debugger support - this is how JupyterLab knows which kernels support debugging; if they support but do not advertise it properly it will not work. Run

    jupyter kernelspec list
    

    And find entries for your custom kernel spec and the default ipykernel, e.g:

    [ListKernelSpecs] Available kernels:
    [ListKernelSpecs]   python3               ~/.pyenv/versions/python3.10/share/jupyter/kernels/python3
    [ListKernelSpecs]   my-custom-kernel      ~/.local/share/jupyter/kernels/my-custom-kernel
    

    Under these paths you will find a file called kernel.json. For the default kernel it should look like:

    {
     "argv": [
      "python",
      "-m",
      "ipykernel_launcher",
      "-f",
      "{connection_file}"
     ],
     "display_name": "Python 3 (ipykernel)",
     "language": "python",
     "metadata": {
      "debugger": true
     }
    }
    

    You need to copy the metadata part advertising debugger support to the kernel.json file of your custom kernel.

    Once you update kernel spec, restart JupyterLab you will be able to activate the debugger by pressing on the bug icon on the toolbar which will turn orange when activated.