Unable to run nbconvert with Python 3.11.4

I had no problem running jupyter nbconvert from the command line with Python 3.10.2. I installed Python 3.11.4 (through pyenv) and now I get the following error message:

Traceback (most recent call last):
File “/Users/limsico/.pyenv/versions/3.11.4/bin/jupyter-nbconvert”, line 5, in
from nbconvert.nbconvertapp import main
File “/Users/limsico/.pyenv/versions/3.11.4/lib/python3.11/site-packages/nbconvert/nbconvertapp.py”, line 186, in
class NbConvertApp(JupyterApp):
File “/Users/limsico/.pyenv/versions/3.11.4/lib/python3.11/site-packages/nbconvert/nbconvertapp.py”, line 245, in NbConvertApp
Options include {get_export_names()}.
^^^^^^^^^^^^^^^^^^
File “/Users/limsico/.pyenv/versions/3.11.4/lib/python3.11/site-packages/nbconvert/exporters/base.py”, line 151, in get_export_names
e = get_exporter(exporter_name)(config=config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/limsico/.pyenv/versions/3.11.4/lib/python3.11/site-packages/nbconvert/exporters/base.py”, line 110, in get_exporter
exporter = items[0].load()
^^^^^^^^^^^^^^^
File “/Users/limsico/.pyenv/versions/3.11.4/lib/python3.11/importlib/metadata/init.py”, line 202, in load
module = import_module(match.group(‘module’))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/limsico/.pyenv/versions/3.11.4/lib/python3.11/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/limsico/.pyenv/versions/3.11.4/lib/python3.11/site-packages/jupyter_contrib_nbextensions/init.py”, line 5, in
import jupyter_nbextensions_configurator
File “/Users/limsico/.pyenv/versions/3.11.4/lib/python3.11/site-packages/jupyter_nbextensions_configurator/init.py”, line 18, in
from notebook.base.handlers import APIHandler, IPythonHandler
ModuleNotFoundError: No module named ‘notebook.base’

jupyter --version gives me:
Selected Jupyter core packages…
IPython : 8.14.0
ipykernel : 6.25.1
ipywidgets : 8.1.0
jupyter_client : 8.3.0
jupyter_core : 5.3.1
jupyter_server : 2.7.1
jupyterlab : 4.0.5
nbclient : 0.8.0
nbconvert : 7.7.4
nbformat : 5.9.2
notebook : 7.0.2
qtconsole : 5.4.3
traitlets : 5.9.0

I’ve reinstalled ipython, notebook, jupyterlab and nbconvert (through pip) and I still get the same error message. When I switch back to Python 3.10.2, everything works fine again.

Any help would be appreciated!

1 Like

Hi ctl360,

did you solve this issue? I go back from 3.11.7 to 3.10.11 on my M$ Win 11 but still get the same error

Traceback (most recent call last):
File “C:\Python310\lib\runpy.py”, line 196, in run_module_as_main
return run_code(code, main_globals, None,
File “C:\Python310\lib\runpy.py”, line 86, in run_code
exec(code, run_globals)
File "C:\Python310\Scripts\jupyter-nbconvert.EXE_main
.py", line 4, in
File “C:\Python310\lib\site-packages\nbconvert\nbconvertapp.py”, line 193, in
class NbConvertApp(JupyterApp):
File “C:\Python310\lib\site-packages\nbconvert\nbconvertapp.py”, line 252, in NbConvertApp
Options include {get_export_names()}.
File “C:\Python310\lib\site-packages\nbconvert\exporters\base.py”, line 145, in get_export_names
e = get_exporter(exporter_name)(config=config)
File “C:\Python310\lib\site-packages\nbconvert\exporters\base.py”, line 106, in get_exporter
exporter = items[0].load()
File "C:\Python310\lib\importlib\metadata_init
.py", line 171, in load
module = import_module(match.group(‘module’))
File "C:\Python310\lib\importlib_init
.py", line 126, in import_module
return bootstrap.gcd_import(name[level:], package, level)
File "C:\Python310\lib\site-packages\jupyter_contrib_nbextensions_init
.py", line 5, in
import jupyter_nbextensions_configurator
File "C:\Python310\lib\site-packages\jupyter_nbextensions_configurator_init
.py", line 18, in
from notebook.base.handlers import APIHandler, IPythonHandler
ModuleNotFoundError: No module named ‘notebook.base’

Also a “simple” jupyter contrib leads to
Traceback (most recent call last):
File “C:\Python310\Scripts\jupyter-contrib-script.py”, line 33, in
sys.exit(load_entry_point(‘jupyter-contrib-core==0.4.2’, ‘console_scripts’, ‘jupyter-contrib’)())
File “C:\Python310\lib\site-packages\jupyter_core\application.py”, line 281, in launch_instance
super().launch_instance(argv=argv, **kwargs)
File “C:\Python310\lib\site-packages\traitlets\config\application.py”, line 1075, in launch_instance
app = cls.instance(**kwargs)
File “C:\Python310\lib\site-packages\traitlets\config\configurable.py”, line 583, in instance
inst = cls(*args, **kwargs)
File “C:\Python310\lib\site-packages\jupyter_contrib_core\application.py”, line 27, in init
self.refresh_subcommands()
File “C:\Python310\lib\site-packages\jupyter_contrib_core\application.py”, line 43, in refresh_subcommands
get_subcommands_dict = entrypoint.load()
File "C:\Python310\lib\site-packages\pkg_resources_init
.py", line 2471, in load
return self.resolve()
File "C:\Python310\lib\site-packages\pkg_resources_init
.py", line 2477, in resolve
module = import(self.module_name, fromlist=[‘name’], level=0)
File “C:\Python310\lib\site-packages\jupyter_contrib_nbextensions_init_.py”, line 5, in
import jupyter_nbextensions_configurator
File “C:\Python310\lib\site-packages\jupyter_nbextensions_configurator_init_.py”, line 18, in
from notebook.base.handlers import APIHandler, IPythonHandler
ModuleNotFoundError: No module named ‘notebook.base’

Do you know a solution?

Thanks a lot!

It looks like the errors are coming from legacy jupyter_contrib_nbextensions and jupyter-contrib-core. Can you uninstall these two packages and see if it works then?

Hi thanks a lot. I tried only uninstalling jupyter_contrib_nbextensions which leads to the issue that jupyter-contrib-core fails. But, and this was my fault, I didn’t uninstall jupyter-contrib-core! However, I solved the “problem” (whereby I was the problem ;-)) in that way that I uninstall (with pip) all packages and add by hand (with pip install) all needed stuff for my work. What I can see, my now working “setup” has the following jupyter and nb* / notebook stuff:

jupyter 1.0.0
jupyter_client 8.6.0
jupyter-console 6.6.3
jupyter_core 5.7.1
jupyter-events 0.9.0
jupyter-lsp 2.2.2
jupyter_server 2.12.5
jupyter_server_proxy 4.1.0
jupyter_server_terminals 0.5.2
jupyterlab 4.0.11
jupyterlab_pygments 0.3.0
jupyterlab_server 2.25.2
jupyterlab-widgets 3.0.9

nbclient 0.9.0
nbconvert 7.14.2
nbformat 5.9.2
widgetsnbextension 4.0.9

notebook 7.0.7
notebook_shim 0.2.3

for jupyter I use pip install jupyter[all]

Thanks again for your help, I assume this will help, but as written I didn’t test it