2

I started facing this error after installing keras via - conda install -c conda-forge keras.

Now when I try to launch Jupiter notebook I am prompted with the following:

Traceback (most recent call last):
  File "C:\Users\srish\Anaconda3\lib\site-packages\jsonschema\__init__.py", line 31, in <module>
    from importlib import metadata
ImportError: cannot import name 'metadata' from 'importlib' (C:\Users\srish\Anaconda3\lib\importlib\__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\srish\Anaconda3\lib\site-packages\nbformat\validator.py", line 12, in <module>
    from jsonschema import ValidationError
  File "C:\Users\srish\Anaconda3\lib\site-packages\jsonschema\__init__.py", line 33, in <module>
    import importlib_metadata as metadata
ModuleNotFoundError: No module named 'importlib_metadata'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\srish\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
    from notebook.notebookapp import main
  File "C:\Users\srish\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 80, in <module>
    from .services.contents.manager import ContentsManager
  File "C:\Users\srish\Anaconda3\lib\site-packages\notebook\services\contents\manager.py", line 17, in <module>
    from nbformat import sign, validate as validate_nb, ValidationError
  File "C:\Users\srish\Anaconda3\lib\site-packages\nbformat\__init__.py", line 32, in <module>
    from .validator import validate, ValidationError
  File "C:\Users\srish\Anaconda3\lib\site-packages\nbformat\validator.py", line 23, in <module>
    raise ImportError(str(e) + verbose_msg)
ImportError: No module named 'importlib_metadata'

    Jupyter notebook format depends on the jsonschema package:

        https://pypi.python.org/pypi/jsonschema

    Please install it first.

The solution of the following link seems to be outdated, and is for python 2.7 only: Can't use Jupyter Notebook: jsonschema apparently missing.

halfer
  • 19,824
  • 17
  • 99
  • 186

3 Answers3

3

Your Solution Worked for me. I had originally upgraded to jsonschema 3.20. I then downgraded to version jsonschema 3.02 and now my Jupyter notebook opens. Don't know why the higher version 3.20 creates the problem.

2

Well I also felt the same problem and my notebook or lab was also not opening. I found an answer in an website. I used the command conda install jsonschema==3.0.2 in the Anaconda Prompt and after installing my notebook and lab works fine again.

2

If you don't mind what version of anaconda you're using, downgrading anaconda to the 2020.02 version solved it for me (using conda install anaconda=2020.02).

This happend to me when I updated anaconda to the 2020.07 version using conda install anaconda=2020.07. I tried conda install jsonschema==3.0.2 as @user14080268 mentioned, but this caused the solving environment to fail and it went to look for incompatible packages, which then took for ever. Downgrading anaconda back to the version I initially had fixed the issue for me!

(of course, if you had a specific reason to update anaconda this might not be the best solution for you)

Anne
  • 51
  • 1
  • 4