Can no longer start jupyter notebook

I am running Ubuntu 22.04.4 LTS and have been using jupyter notebooks for years.

Yesterday, I tried running it and found the following error:

$ jupyter notebook
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/notebook/traittypes.py", line 232, in _resolve_classes
    klass = self._resolve_string(klass)
  File "/home/fpoulin/.local/lib/python3.10/site-packages/traitlets/traitlets.py", line 2015, in _resolve_string
    return import_item(string)
  File "/home/fpoulin/.local/lib/python3.10/site-packages/traitlets/utils/importstring.py", line 33, in import_item
    module = __import__(package, fromlist=[obj])
ModuleNotFoundError: No module named 'jupyter_server.contents'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/jupyter-notebook", line 33, in <module>
    sys.exit(load_entry_point('notebook==6.4.8', 'console_scripts', 'jupyter-notebook')())
  File "/home/fpoulin/.local/lib/python3.10/site-packages/jupyter_core/application.py", line 283, in launch_instance
    super().launch_instance(argv=argv, **kwargs)
  File "/home/fpoulin/.local/lib/python3.10/site-packages/traitlets/config/application.py", line 1073, in launch_instance
    app = cls.instance(**kwargs)
  File "/home/fpoulin/.local/lib/python3.10/site-packages/traitlets/config/configurable.py", line 583, in instance
    inst = cls(*args, **kwargs)
  File "/home/fpoulin/.local/lib/python3.10/site-packages/traitlets/traitlets.py", line 1292, in __new__
    inst.setup_instance(*args, **kwargs)
  File "/home/fpoulin/.local/lib/python3.10/site-packages/traitlets/traitlets.py", line 1335, in setup_instance
    super(HasTraits, self).setup_instance(*args, **kwargs)
  File "/home/fpoulin/.local/lib/python3.10/site-packages/traitlets/traitlets.py", line 1311, in setup_instance
    init(self)
  File "/usr/lib/python3/dist-packages/notebook/traittypes.py", line 223, in instance_init
    self._resolve_classes()
  File "/usr/lib/python3/dist-packages/notebook/traittypes.py", line 235, in _resolve_classes
    warn(f"{klass} is not importable. Is it installed?", ImportWarning)
TypeError: warn() missing 1 required keyword-only argument: 'stacklevel'


Below are the specs of my system and I presume one of them is causing the problems. Can anyone tell me which one I should update or downgrade?

$ jupyter --version
Selected Jupyter core packages...
IPython          : 7.31.1
ipykernel        : 6.7.0
ipywidgets       : 6.0.0
jupyter_client   : 8.6.2
jupyter_core     : 5.7.2
jupyter_server   : 2.14.1
jupyterlab       : not installed
nbclient         : 0.5.6
nbconvert        : 7.16.4
nbformat         : 5.10.4
notebook         : 6.4.8
qtconsole        : not installed
traitlets        : 5.14.3

It turns out that this fixed my problem.

pip install --upgrade notebook

2 Likes

“pip install --upgrade notebook”

That worked for me as well (12/23/2024)