jiho
jiho

Reputation: 103

Jupiter notebook run error: AttributeError: module 'importlib_metadata' has no attribute 'version'

Originally, Jupyter notebook was running well without any problems. But after installing tensorflow and keras today, it doesn't work.

Error message:

Traceback (most recent call last):
  File "C:\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
    from notebook.notebookapp import main
  File "C:\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 85, in <module>
    from .services.contents.manager import ContentsManager
  File "C:\Anaconda3\lib\site-packages\notebook\services\contents\manager.py", line 17, in <module>
    from nbformat import sign, validate as validate_nb, ValidationError
  File "C:\Anaconda3\lib\site-packages\nbformat\__init__.py", line 32, in <module>
    from .validator import validate, ValidationError
  File "C:\Anaconda3\lib\site-packages\nbformat\validator.py", line 12, in <module>
    from .json_compat import get_current_validator, ValidationError
  File "C:\Anaconda3\lib\site-packages\nbformat\json_compat.py", line 10, in <module>
    import jsonschema
  File "C:\Anaconda3\lib\site-packages\jsonschema\__init__.py", line 34, in <module>
    __version__ = metadata.version("jsonschema")
AttributeError: module 'importlib_metadata' has no attribute 'version'

Upvotes: 8

Views: 19554

Answers (3)

Eugene U
Eugene U

Reputation: 61

For me, the same error happened after VSCode proposed me to install a tensorboard plugin and I pressed yes. (MacOS 11.4, Conda 4.10.3)

It appears that it introduced some kind of version mismatch for multiple packages in the environment.

The following fixed the problem:

conda update --all

Upvotes: 4

Chandrika Deb
Chandrika Deb

Reputation: 111

This is a problem with the Anaconda version upgrade. You can solve this with the following command that worked for me.

conda install -c conda-forge importlib_metadata

Upvotes: 6

Jose Manuel Tamez
Jose Manuel Tamez

Reputation: 171

There is a problem with your importlib_metadata package, you can try uninstall it first and then forcing out a new installation with the following commands:

pip uninstall importlib_metadata 
pip install importlib_metadata --force-reinstall

It worked for me.

Upvotes: 17

Related Questions