ipywidgets
ipywidgets copied to clipboard
KeyError: 'The Python module widgetsnbextension is not a valid nbextension, it is missing the `_jupyter_nbextension_paths()` method.'
Description
Hello, I want to use dev_ Install.sh for source code compilation and installation, but I encountered the following error:
KeyError: 'The Python module widgetsnbextension is not a valid nbextension, it is missing the _jupyter_nbextension_paths() method.'

If using JupyterLab
- JupyterLab version:3.5.2
Some more information about the relevant installed versions of notebook, jupyter_server, traitlets, ipywidgets, with e.g. pip freeze would help a lot.
I'm faced with the same problem. When I try to use "interact" modul, it dosen't work and raise this KeyError. Dose anyone know what should I do?
faced with the same problem T^T
Since Jupyter Notebook v7, running this command is not needed anymore. May I suggest updating Jupyter Notebook to the latest? If running JupyterLab, this command was never required.
I think there will be a long tail of users who are for various reasons limited to notebook 6.
Maybe there is a widgetsnbextension directory, and python see it as a namespace package. Could you run:
$ python -c "import widgetsnbextension as w; print(dir(w), w.__file__)"
My output is:
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__', '__spec__', '__version__', '_jupyter_nbextension_paths', '_version', 'warn']
/Users/maartenbreddels/miniconda3/envs/dev/lib/python3.9/site-packages/widgetsnbextension/__init__.py
I think there will be a long tail of users who are for various reasons limited to notebook 6.
Maybe there is a widgetsnbextension directory, and python see it as a namespace package. Could you run:
$ python -c "import widgetsnbextension as w; print(dir(w), w.__file__)"My output is:
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_jupyter_nbextension_paths', '_version', 'warn'] /Users/maartenbreddels/miniconda3/envs/dev/lib/python3.9/site-packages/widgetsnbextension/__init__.py
after running: python -c "import widgetsnbextension as w; print(dir(w), w.file)" my output is: ['builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'path', 'spec', 'version', '_jupyter_nbextension_paths', 'version', 'warn'] C:\Users\jiali\anaconda3\lib\site-packages\widgetsnbextension_init.py
Odd, as you can see _jupyter_nbextension_paths is present, so everything seems fine.
What are the outputs of which jupyter, which jupyter-nbextension and which python ?
Sorry, my system is win11. What command is equal to 'which'?
I have no idea, but which tells you where the executable lives that you would execute if you ran it in the terminal. Sometimes the python executable and the jupyter (or jupyter-nbextension ) executable live in different environments. Knowing the paths to those executable will tell me if that option can be excluded or not.
Thanks so much for Martin's and Maarten's advice. I faced this issue because I wanted to import ipdb in jupyter notebook. and chatGPT told me to do the following:
jupyter nbextension enable --py --sys-prefix widgetsnbextension; jupyter nbextension enable --py --sys-prefix ipywidgets jupyter nbextension enable --py --sys-prefix ipdb
though these 2 command: "jupyter nbextension enable --py --sys-prefix ipywidgets; jupyter nbextension enable --py --sys-prefix ipdb" still can't run, as Martin suggested I tried ipdb and it seems working now. So I think I could put aside this issue now, hoping won't affect other programs.