jupyter notebook闪退打不开的解决方法,供大家参考

以前装了 jupyter notebook ,可以用的(pip install jupyter),但是没过一阵子就发现用不了了,泪崩,还没当回事,但上周数据挖掘作业一定要用到jupyter notebook,搞了好几天都没发现问题所在,今天早上看了一篇博客终于知道怎么回事了

https://blog.csdn.net/candcplusplus/article/details/72793591

首先我在控制台(cmd)打开 jupyter notebook是这样的         

C:\Users\17119>jupyter notebook
Traceback (most recent call last):
  File "c:\users\17119\appdata\local\programs\python\python36-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\17119\appdata\local\programs\python\python36-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\17119\AppData\Local\Programs\Python\Python36-32\Scripts\jupyter-notebook.EXE\__main__.py", line 5, in 
  File "c:\users\17119\appdata\local\programs\python\python36-32\lib\site-packages\notebook\notebookapp.py", line 38, in 
    from jinja2 import Environment, FileSystemLoader
  File "c:\users\17119\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\__init__.py", line 33, in 
    from jinja2.environment import Environment, Template
  File "c:\users\17119\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\environment.py", line 15, in 
    from jinja2 import nodes
  File "c:\users\17119\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\nodes.py", line 19, in 
    from jinja2.utils import Markup
  File "c:\users\17119\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\utils.py", line 647, in 
    from markupsafe import Markup, escape, soft_unicode
  File "c:\users\17119\appdata\local\programs\python\python36-32\lib\site-packages\markupsafe\__init__.py", line 14, in 
    from markupsafe._compat import text_type, string_types, int_types, \

ModuleNotFoundError: No module named 'markupsafe._compat'

注意,打开notebook后不是我这样的用不来我下面的解决办法,请自行找其他方法吧~

注意到最后一句话:No module named 'markupsafe._compat' ——我擦,居然说这个包里面找不到_compat.py文件,我当时就很纳闷,难道我pip 装的包会有缺失?那不是扯淡吗。

然后就问度娘, 他娘累,真有跟我一样的,赶紧找到 这个markupmarkupsafe 文件夹——File "c:\users\17119\appdata\local\programs\python\python36-32\lib\site-packages\markupsafe\__init__.py", line 14, in 其实这里已经写好路径了,你只要直接复制c:\users\17119\appdata\local\programs\python\python36-32\lib\site-packages\markupsafe就可以进入了,(17119是window下我的用户名,每个人不一样的,然后为什么我让你们复制路径进入文件夹呢,因为找的话那个appdata文件是你们找不到的,因为是隐藏文件,你也可以显示隐藏文件,这个你们自己百度),打开后

是这样的:

jupyter notebook闪退打不开的解决方法,供大家参考_第1张图片

当时就我擦嘞,果然没有 那个_cmpat.py文件,赶紧加进去,内容:

# -*- coding: utf-8 -*-
"""
    markupsafe._compat
    ~~~~~~~~~~~~~~~~~~
    Compatibility module for different Python versions.
    :copyright: (c) 2013 by Armin Ronacher.
    :license: BSD, see LICENSE for more details.
"""
import sys
PY2 = sys.version_info[0] == 2
if not PY2:
    text_type = str
    string_types = (str,)
    unichr = chr
    int_types = (int,)
    iteritems = lambda x: iter(x.items())
else:
    text_type = unicode
    string_types = (str, unicode)
    unichr = unichr
    int_types = (int, long)

    iteritems = lambda x: x.iteritems()

保存,如下:

jupyter notebook闪退打不开的解决方法,供大家参考_第2张图片

然后 抱着试一试的心态,运行jupyter notebook

jupyter notebook闪退打不开的解决方法,供大家参考_第3张图片jupyter notebook闪退打不开的解决方法,供大家参考_第4张图片

成功!amazing!

你可能感兴趣的:(jupyter notebook闪退打不开的解决方法,供大家参考)