jupyter / nbconvert

Jupyter Notebook Conversion
https://nbconvert.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.72k stars 564 forks source link

Jupyter nbconvert exceptions in Jupyter Lab 3 #1956

Open madhulika189 opened 1 year ago

madhulika189 commented 1 year ago

Hi All,

I was using a nbconvert command in my lifecycle configuration of a notebook execution. It was initially running seamlessly when I was using jupyter lab 1. I recently had to migrate to Jupyter Lab 3 as a part of required migration and now my command wont stop throwing exceptions.

For context, here are my current package versions:

# Name                    Version                   Build  Channel
ipykernel                 6.20.1             pyh210e3f2_0    conda-forge
ipython                   8.8.0              pyh41d4057_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                8.0.4                    pypi_0    pypi
jsonschema                3.2.0                    pypi_0    pypi
jupyter                   1.0.0           py310hff52083_8    conda-forge
jupyter_client            7.3.4              pyhd8ed1ab_0    conda-forge
jupyter_console           6.4.4              pyhd8ed1ab_0    conda-forge
jupyter_core              5.1.3           py310hff52083_0    conda-forge
jupyter_server            1.23.4             pyhd8ed1ab_0    conda-forge
jupyterlab                3.5.2              pyhd8ed1ab_0    conda-forge
jupyterlab-widgets        3.0.5                    pypi_0    pypi
jupyterlab_pygments       0.2.2              pyhd8ed1ab_0    conda-forge
jupyterlab_server         2.18.0             pyhd8ed1ab_0    conda-forge
nbclassic                 0.4.8              pyhd8ed1ab_0    conda-forge
nbclient                  0.7.2              pyhd8ed1ab_0    conda-forge
nbconvert                 7.2.7              pyhd8ed1ab_0    conda-forge
nbconvert-core            7.2.7              pyhd8ed1ab_0    conda-forge
nbconvert-pandoc          7.2.7              pyhd8ed1ab_0    conda-forge
nbformat                  5.7.1              pyhd8ed1ab_0    conda-forge

My command is

jupyter nbconvert --to notebook --inplace --ExecutePreprocessor.enabled=True --ExecutePreprocessor.timeout=-1 --ExecutePreprocessor.kernel_name=python3 --ExecutePreprocessor.store_widget_state=False --execute "$NOTEBOOK_FILE" & 

Here are my logs

[W 2023-03-01 17:50:34.174 ServerApp] jupyter_server_fileid | error adding extension (enabled: True): The module 'jupyter_server_fileid' could not be found (No module named 'jsonschema.protocols'). Are you sure the extension is installed?
    Traceback (most recent call last):
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_server/extension/manager.py", line 175, in _validate_name
        self._module, self._metadata = get_metadata(name)
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_server/extension/utils.py", line 55, in get_metadata
        module = importlib.import_module(package_name)
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_server_fileid/__init__.py", line 2, in <module>
        from .extension import FileIdExtension
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_server_fileid/extension.py", line 1, in <module>
        from jupyter_events.logger import EventLogger
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_events/__init__.py", line 3, in <module>
        from .logger import EVENTS_METADATA_VERSION, EventLogger
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_events/logger.py", line 19, in <module>
        from .schema_registry import SchemaRegistry
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_events/schema_registry.py", line 3, in <module>
        from .schema import EventSchema
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_events/schema.py", line 6, in <module>
        from jsonschema.protocols import Validator
    ModuleNotFoundError: No module named 'jsonschema.protocols'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_server/extension/manager.py", line 320, in add_extension
        extpkg = ExtensionPackage(name=extension_name, enabled=enabled)
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_server/extension/manager.py", line 166, in __init__
        super().__init__(*args, **kwargs)
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/traitlets/traitlets.py", line 1361, in __init__
        value = self._traits[key]._cross_validate(self, getattr(self, key))
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/traitlets/traitlets.py", line 746, in _cross_validate
        value = obj._trait_validators[self.name](obj, proposal)
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/traitlets/traitlets.py", line 1233, in __call__
        return self.func(*args, **kwargs)
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_server/extension/manager.py", line 179, in _validate_name
        "sure the extension is installed?".format(name=name, e=e)
    jupyter_server.extension.utils.ExtensionModuleNotFound: The module 'jupyter_server_fileid' could not be found (No module named 'jsonschema.protocols'). Are you sure the extension is installed?

[W 2023-03-01 17:50:36.763 ServerApp] jupyter_server_terminals | error adding extension (enabled: True): The module 'jupyter_server_terminals' could not be found (No module named 'jupyter_server_terminals'). Are you sure the extension is installed?
    Traceback (most recent call last):
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_server/extension/manager.py", line 175, in _validate_name
        self._module, self._metadata = get_metadata(name)
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_server/extension/utils.py", line 55, in get_metadata
        module = importlib.import_module(package_name)
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'jupyter_server_terminals'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_server/extension/manager.py", line 320, in add_extension
        extpkg = ExtensionPackage(name=extension_name, enabled=enabled)
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_server/extension/manager.py", line 166, in __init__
        super().__init__(*args, **kwargs)
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/traitlets/traitlets.py", line 1361, in __init__
        value = self._traits[key]._cross_validate(self, getattr(self, key))
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/traitlets/traitlets.py", line 746, in _cross_validate
        value = obj._trait_validators[self.name](obj, proposal)
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/traitlets/traitlets.py", line 1233, in __call__
        return self.func(*args, **kwargs)
      File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/jupyter_server/extension/manager.py", line 179, in _validate_name
        "sure the extension is installed?".format(name=name, e=e)
    jupyter_server.extension.utils.ExtensionModuleNotFound: The module 'jupyter_server_terminals' could not be found (No module named 'jupyter_server_terminals'). Are you sure the extension is installed?

I tried all the obvious steps of importing the modules, downgrading jsonschema and jupyter version, but it keeps breaking other code.

Is this a bug/backward compatibility issue?

Oriochi commented 1 year ago

hi, i have the same issue. Just like you, i tried all the obvious steps of importing the modules, but it didn´t work. I´ll keep trying another ways to solve it, if i found how to solve it, i´ll let you know.

tuncbkose commented 1 year ago

I think you should be updating jsonschema, not downgrading it. For example, jupyterlab_server==2.18.0 lists jsonschema>=4.17.3 in its dependencies, and you have an older version.