jupyter notebook 突然打不开问题解决

环境

win10
anaconda3(2020.02)

原因

执行了 conda 升级命令,升级了 conda 下管理的包,导致 jsonschema 升级到 3.2.0

解决办法:

在jupyter的环境下,执行下面语句,默认环境是 (base)
pip install jsonschema==3.0.2

解决过程:

最近使用jupyter过程中,隔了几天没开 jupyter notebook,当我重新打开的时候,发现出现了打不开的情况,从开始菜单中直接打开的现象是黑框出现,然后闪退。
直接运行 jupyter notebook 的脚本,查看出错log

D:\> python D:\software\work\Anaconda\Anaconda\Scripts\jupyter-notebook-script.py

运行信息如下:

Traceback (most recent call last):
  File "D:\software\work\Anaconda\Anaconda\lib\site-packages\jsonschema\__init__.py", line 31, in 
    from importlib import metadata
ImportError: cannot import name 'metadata' from 'importlib' (D:\software\work\Anaconda\Anaconda\lib\importlib\__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\software\work\Anaconda\Anaconda\lib\site-packages\nbformat\validator.py", line 12, in 
    from jsonschema import ValidationError
  File "D:\software\work\Anaconda\Anaconda\lib\site-packages\jsonschema\__init__.py", line 33, in 
    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 "D:\software\work\Anaconda\Anaconda\Scripts\jupyter-notebook-script.py", line 6, in 
    from notebook.notebookapp import main
  File "D:\software\work\Anaconda\Anaconda\lib\site-packages\notebook\notebookapp.py", line 80, in 
    from .services.contents.manager import ContentsManager
  File "D:\software\work\Anaconda\Anaconda\lib\site-packages\notebook\services\contents\manager.py", line 17, in 
    from nbformat import sign, validate as validate_nb, ValidationError
  File "D:\software\work\Anaconda\Anaconda\lib\site-packages\nbformat\__init__.py", line 32, in 
    from .validator import validate, ValidationError
  File "D:\software\work\Anaconda\Anaconda\lib\site-packages\nbformat\validator.py", line 23, in 
    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.

可以看到是 jsonschema 这个地方失败了。

通过 conda list 查看安装的包,发现我是有安装这个包的
在这里插入图片描述
经过一番折腾查找才得知,需要用 3.0.2 的版本,3.2.0这个版本在当前的jupyter中不支持,因此需要重新安装一次 jsonschema

安装命令: pip install jsonschema==3.0.2
可以正常打开 jupyter notebook 了,完美解决。

你可能感兴趣的:(python,Machine,Learning,jupyter,深度学习,打不开)