ImportError: No module named 'jupyter_nbextensions_configurator'
Closed this issue Β· 15 comments
On the newest debian, I installed nbextensions using:
pip install --user jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
pip install --user jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user
No error messages, but when I start the jupyter notebook, I get:
[W 19:06:37.081 NotebookApp] Error loading server extension jupyter_nbextensions_configurator
Traceback (most recent call last):
File "/home/stan/.local/lib/python3.5/site-packages/notebook/notebookapp.py", line 1339, in init_server_extensions
mod = importlib.import_module(modulename)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'jupyter_nbextensions_configurator'
Curiously, I don't get an error message if I execute in python: jupyter_nbextensions_configurator
Does anyone have an idea what might have gone wrong?
I even tried uninstalling and re-installing directly from master, but with the same result.
Hmm, the only thing I can think of would be if somehow the packages have been installed into a different python (virtual?) environment than the one you're using to run the notebook server - how are you running the server? Are you using virtualenv, conda, or any other environment manager?
Thanks for the quick reply. I only now installed virtualenvwrapper but i didn't have it before. I was just running jupyter notebook
from the command line. Is there a way to find out if some packages have been installed in the wrong environment? I must admit that my previous installations of jupyter had failed because I was missing build-essential
and then I installed jupyter-notebook through aptitude before I figured out how to do it with pip on my system. Could this cause some confusion?
Could this cause some confusion?
Possibly. It seems as though your apt-installed jupyter notebook
may not be using the same python as your pip commands are installing into, though I'm not sure.
So, to shed some light on this, you might try in a terminal:
which python
which jupyter
which jupyter-notebook
which jupyter-nbextensions_configurator
and from a notebook and a command-line python prompt, try
import os
from jupyter_nbextensions_configurator import __file__
print(os.path.realpath(__file__))
also
which pip
Just to be sure, I did a clean install in a virtual environment and get:
(master *%)stan@debian-stan:~/notebooks/jupyter$ which python
/home/stan/.virtualenvs/sympy/bin/python
(master *%)stan@debian-stan:~/notebooks/jupyter$ which jupyter
/home/stan/.virtualenvs/sympy/bin/jupyter
(master *%)stan@debian-stan:~/notebooks/jupyter$ which jupyter-notebook
/home/stan/.virtualenvs/sympy/bin/jupyter-notebook
(master *%)stan@debian-stan:~/notebooks/jupyter$ which jupyter-nbextensions_configurator
/home/stan/.virtualenvs/sympy/bin/jupyter-nbextensions_configurator
(master *%)stan@debian-stan:~/notebooks/jupyter$ which pip
/home/stan/.virtualenvs/sympy/bin/pip
(master *%)stan@debian-stan:~/notebooks/jupyter$ python
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> from jupyter_nbextensions_configurator import __file__
>>> print(os.path.realpath(__file__))
/home/stan/.virtualenvs/sympy/lib/python2.7/site-packages/jupyter_nbextensions_configurator/__init__.pyc
However, inside a notebook:
%%sh
which jupyter
/home/stan/.local/bin/jupyter
Very strange.
I now re-installed everything from inside the jupyter notebook:
%%sh
pip install --user jupyter_contrib_nbextensions
jupyter contrib nbextension install --user --skip-running-check
pip install --user jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user
...no error returned. It even reports:
Enabling: jupyter_nbextensions_configurator
- Writing config: /home/stan/.jupyter
- Validating...
jupyter_nbextensions_configurator OK
Enabling notebook nbextension nbextensions_configurator/config_menu/main...
Enabling tree nbextension nbextensions_configurator/tree_tab/main...
[I 00:25:26 InstallContribNbextensionsApp] Enabling notebook extension contrib_nbextensions_help_item/main...
[I 00:25:26 InstallContribNbextensionsApp] - Validating: OK
[I 00:25:26 InstallContribNbextensionsApp] - Editing config: /home/stan/.jupyter/jupyter_nbconvert_config.json
[I 00:25:26 InstallContribNbextensionsApp] -- Configuring nbconvert template path
[I 00:25:26 InstallContribNbextensionsApp] -- Configuring nbconvert preprocessors
[I 00:25:26 InstallContribNbextensionsApp] - Writing config: /home/stan/.jupyter/jupyter_nbconvert_config.json
[I 00:25:26 InstallContribNbextensionsApp] -- Writing updated config file /home/stan/.jupyter/jupyter_nbconvert_config.json
Enabling: jupyter_nbextensions_configurator
- Writing config: /home/stan/.jupyter
- Validating...
jupyter_nbextensions_configurator OK
Enabling notebook nbextension nbextensions_configurator/config_menu/main...
Enabling tree nbextension nbextensions_configurator/tree_tab/main...
However:
%%sh
which pip
which jupyter
which jupyter_contrib_nbextensions
which jupyter_nbextensions_configurator
gives:
/home/stan/.local/bin/pip
/home/stan/.local/bin/jupyter
and from jupyter_nbextensions_configurator import __file__
gives ΓmportError
.
I think there is a problem with my jupyter and/or pip installation, as whatever I install using pip is not available in the jupyter notebook.
Yes, this is getting confusing π It seems to stem from environment (paths) not being conserved from the virtualenv to the notebook server-spawned kernels. You were running the notebook server from the virtualenv I suppose? I'm not sure how the %sh
magic goes about constructing an environment though anyway, to be honest.
Anyway, there are a couple of things to address here:
- You've made a couple of typos in your
which
commands from the notebook%%sh
magic - note the hyphens vs underscores - you need to check forjupyter-contrib-nbextensions
(both hyphens) andjupyter-nbextensions_configurator
(first hyphen, second underscore). - It's possible that your use of the
--user
flag on yourpip install
commands may be the culprit here, in that it will install things to~/.local
, but this may not be on the python path (distinct from shell path). It's probably better to omit the--user
flag from thepip install
command if possible (though it serves a subtly different purpose for the extension install commands, where you can safely keep it).
Following https://stackoverflow.com/questions/32680081/importerror-after-successful-pip-installation#32680082, I now used python -m pip install
instead of just pip install
from within the notebook. The following code from within a notebook started in a virtualenv did the trick:
%%sh
python -m pip install --user jupyter_contrib_nbextensions
jupyter contrib nbextension install --user --skip-running-check
python -m pip install --user jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user
After re-starting the notebook, the Nbextensions tab appeared. Actually, I think I executed the above code within a notebook that was run from outside the virtualenv, not sure. Thanks for your help! I don't understand what happened there, but it seems to work now.
I don't understand what happened there, but it seems to work now.
π€£ I can't say I understand either, but I'm glad you got it working eventually!
Following https://stackoverflow.com/questions/32680081/importerror-after-successful-pip-installation#32680082, I now used
python -m pip install
instead of justpip install
from within the notebook. The following code from within a notebook started in a virtualenv did the trick:%%sh python -m pip install --user jupyter_contrib_nbextensions jupyter contrib nbextension install --user --skip-running-check python -m pip install --user jupyter_nbextensions_configurator jupyter nbextensions_configurator enable --userAfter re-starting the notebook, the Nbextensions tab appeared. Actually, I think I executed the above code within a notebook that was run from outside the virtualenv, not sure. Thanks for your help! I don't understand what happened there, but it seems to work now.
i met the same problem in windows10 with python 3,6
but it seems not work for mine computer
@wangzihan11 In my case, the notebook kernel was from a virtual environment but I was launching jupyter from the global environment. I have the jupyter_contrib_nbextensions installed on my global environment but not in the virtual environment. So when running the following jupyter command jupyter nbconvert --to script <>.ipynb
, I was getting the following error: ModuleNotFoundError: No module named
jupyter_contrib_nbextensions'`. I realize that the error message is a bit different than the title for this post but I think the issues are related.
The way fixed it was to install the jupyter_contrib_nbextensions in the venv: pip install jupyter_contrib_nbextensions
. Another way to fix it could be to remove this extension from the global environment.
I had trouble installing in my new mac, which already came with python3. I installed Jupyter through brew. Not sure if this will help anyone, but I'll include what worked for me below.
When I would start the notebook, I would get:
ModuleNotFoundError: No module named 'jupyter_nbextensions_configurator'
First, if you installed these from within jupyter, uninstall them (use python or python3 as needed based on your environment):
%%sh
python3 -m pip uninstall -y jupyter_contrib_nbextensions
python3 -m pip uninstall -y jupyter_nbextensions_configurator
Similarly, uninstall them through terminal if you installed them there too.
Within jupyter, run these separately:
import sys
sys.executable
sys.path
!{sys.executable} -m pip install jupyter_contrib_nbextensions
!{sys.executable} -m pip install jupyter_nbextensions_configurator
%%sh
jupyter contrib nbextension install --user --skip-running-check
jupyter nbextensions_configurator enable --user
restart jupyter and good luck!
In case this helps anyone, I tried this with a brand new environment and when this error comes up, installing jupyter_contrib_nbextensions
from the source recommended in the repository solves it:
conda install -c conda-forge jupyter_contrib_nbextensions
I just ran into the same problem again and found my own thread, but now with these updates, thanks to everyone! I can confirm that @oscgonfer gave the best solution. Avoid pip install
inside a conda environment if you can, as pip can silently down-grade packages and break your environment! So the best solution is, as stated above:
conda install -c conda-forge jupyter_contrib_nbextensions