ipywidgets icon indicating copy to clipboard operation
ipywidgets copied to clipboard

KeyError: 'The Python module widgetsnbextension is not a valid nbextension, it is missing the `_jupyter_nbextension_paths()` method.'

Open Zxlan opened this issue 2 years ago • 10 comments

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

Zxlan avatar Feb 03 '23 06:02 Zxlan

Some more information about the relevant installed versions of notebook, jupyter_server, traitlets, ipywidgets, with e.g. pip freeze would help a lot.

bollwyvl avatar Feb 08 '23 16:02 bollwyvl

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? image

Pittmann-XIE avatar Jun 05 '23 17:06 Pittmann-XIE

faced with the same problem T^T

Zhaoxi-Liu avatar Oct 12 '23 12:10 Zhaoxi-Liu

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.

martinRenou avatar Oct 13 '23 07:10 martinRenou

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

maartenbreddels avatar Oct 13 '23 09:10 maartenbreddels

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

Zhaoxi-Liu avatar Oct 17 '23 13:10 Zhaoxi-Liu

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 ?

maartenbreddels avatar Oct 17 '23 14:10 maartenbreddels

Sorry, my system is win11. What command is equal to 'which'?

Zhaoxi-Liu avatar Oct 17 '23 14:10 Zhaoxi-Liu

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.

maartenbreddels avatar Oct 17 '23 14:10 maartenbreddels

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.

Zhaoxi-Liu avatar Oct 18 '23 05:10 Zhaoxi-Liu