安装 jupyter notebook 出现 ModuleNotFoundError: No module named 'markupsafe._compat' 错误

时间:2023-03-09 07:52:45
安装 jupyter notebook 出现 ModuleNotFoundError: No module named 'markupsafe._compat' 错误

  使用

 python -m pip install jupyter

  安装完成 jupyter notebook 之后,在命令行界面输入 "jupyter notebook "指令打开时,出现错误:ModuleNotFoundError: No module named 'markupsafe._compat'

安装 jupyter notebook 出现 ModuleNotFoundError: No module named 'markupsafe._compat' 错误

  解决方法:在 markupsafe 文件夹下添加一个 .compat.py 文件即可:

  markupsafe 文件夹在 Python 安装路径下:Python ->Python36 -> Lib -> site-packages -> markupsafe  ,比如我的:

 C:\Users\\AppData\Local\Programs\Python\Python36\Lib\site-packages\markupsafe

  在此文件夹下添加 .compat.py 文件,点此下载(解压后将文件放在 markupsafe 文件夹下即可)。

附: .compat.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()