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

I’m getting a similar problem using

python 3.11
nbconvert 7.16.2
jupyterlab 4.1.4

ModuleNotFoundError: No module named ‘jupyter_contrib_nbextensions’

When running

jupyter nbconvert --to latex .

I cant not find jupyter_contrib_nbextensions dependency on

Installation — nbconvert 7.16.2 documentation.

Moreover search for jupyter_contrib_nbextensions on the whole space does not return any resuls.

Where this package is comming from?

I’m still able to conver ipynb to latex in jupyter lab , what is not that convenient for automation.

Any updates / hints?

Thank you,
Sergey

I have the same problem. I’m creating an environment from scratch, using a requirements file that used to work, but it seems like the latest version of jupyter and nbconvert are not getting along.

I’m stumped for now – I hope someone figures it out soon!

It probably shouldn’t return any results looking for that in your system space. jupyter_contrib_nbextensions is the old Jupyter Notebook unofficial, user-contributed extensions, see here. It isn’t pertinent to JupyterLab 4. Or now Jupyter Notebook 7+.

Do you have any old stuff around interferring?

  • For example here someone had a file jupyter_nbconvert_config.json. Similar reports elsewhere in that thread. Maybe investigate in those highlighted locations?

  • Or here someone had to uninstall some one packages. Note that there someone says much along the lines of what I said at the start of this post.

There was a report a few years ago that the environment was picking up configuration from the system Python here.
It was basically old stuff interfering though, as I discussed in my reply to Sergey.

HI @fomightez , now I’m confused even more.
Do I need to install nbconvert?

Here are my dependencies ( extract from pyproject)

[tool.poetry.dependencies]

python = “~3.11”

numpy = “^1.26.3”

scipy = “^1.11.4”

matplotlib = “^3.8.2”

pandas = “^2.1.4”

nltk = “^3.8.1”

sympy = “^1.12”

jupyterlab = “^4.0.10”

pandera = “^0.18.0”

polars = “^0.20.5”

itables = “^1.6.3”

black = {extras = [“jupyter”], version = “^23.12.1”}

quantstats = “0.0.62”

cufflinks = “^0.17.3”

sqlalchemy = “^2.0.25”

statsmodels = “^0.14.1”

pyarrow = “^15.0.0”

nbconvert = “^7.16.2”

fitz = “^0.0.1.dev2”

frontend = “^0.0.3”

pymupdf = “^1.23.26”

chardet = “^5.2.0”

Can you suggest based on avove what I’m doing wrong.

Thank you,
Sergey

I see JupyterLab 4 and that is fairly new and different than older tech you may have had on your machine. If you didn’t start with only installing that it is easy to have other things around that could be messing things up.
The main point in my reply was that you may have old things interfering and should look for those and deal appropriately.