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 <module> File "c:\users\17119\appdata\local\programs\python\python36-32\lib\site-packages\notebook\notebookapp.py", line 38, in <module> from jinja2 import Environment, FileSystemLoader File "c:\users\17119\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\__init__.py", line 33, in <module> 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 <module> from jinja2 import nodes File "c:\users\17119\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\nodes.py", line 19, in <module> from jinja2.utils import Markup File "c:\users\17119\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\utils.py", line 647, in <module> 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 <module> 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
是這樣的:
當時就我擦嘞,果然沒有 那個_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
成功!amazing!