如何在 Jupyter Notebook 中使用 Mermaid?
我想在 Jupyter Notebook 中使用 Mermaid 绘制流程图(原生的 Jupyter,而 不是 Visual Stdio Code 之类的移植版本。),但是无法实现这个功能。首先是我找到了这个博客:如何在jupyterlab里写mermaid语法支持的graph_vivisol的博客-CSDN博客。
我按照网上现成的信息安装 jupyterlab-mermaid
,但是反馈找不到这个模块。pip install jupyterlab-mermaid
报错如下:
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
ERROR: Could not find a version that satisfies the requirement jupyterlab-mermaid (from versions: none)
ERROR: No matching distribution found for jupyterlab-mermaid
WARNING: You are using pip version 21.2.4; however, version 23.2.1 is available.
You should consider upgrading via the 'D:\Python\Python39\python.exe -m pip install --upgrade pip' command.
我在 GitHub 上找到了这个项目:nb-mermaid : DEPRECATED Mermaid diagrams in the Jupyter Notebook,从项目的 About 上来看可能是已经废弃了的。
我按照项目的 README
执行了 pip install nb-mermaid
,报错信息如下:
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting nb-mermaid
Downloading https://mirrors.aliyun.com/pypi/packages/b9/40/c721865ce3ce642a335b22cdc565586017636337eeab4a40e59ad27e2fd1/nb-mermaid-0.1.0.tar.gz (161 kB)
|████████████████████████████████| 161 kB 1.3 MB/s
ERROR: Command errored out with exit status 1:
command: 'D:\Python\Python39\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\asus\\AppData\\Local\\Temp\\pip-install-f5bpcwhe\\nb-mermaid_56b617d41ad946938db0aa835dcc72a4\\setup.py'"'"'; __file__='"'"'C:\\Users\\asus\\AppData\\Local\\Temp\\pip-install-f5bpcwhe\\nb-mermaid_56b617d41ad946938db0aa835dcc72a4\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\asus\AppData\Local\Temp\pip-pip-egg-info-z_phkng7'
cwd: C:\Users\asus\AppData\Local\Temp\pip-install-f5bpcwhe\nb-mermaid_56b617d41ad946938db0aa835dcc72a4\
Complete output (33 lines):
Traceback (most recent call last):
File "D:\Python\Python39\Lib\site-packages\jupyterpip\__init__.py", line 55, in cmdclass
from notebook.nbextensions import install_nbextension
ModuleNotFoundError: No module named 'notebook.nbextensions'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Python\Python39\Lib\site-packages\IPython\utils\timing.py", line 27, in <module>
import resource
ModuleNotFoundError: No module named 'resource'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\asus\AppData\Local\Temp\pip-install-f5bpcwhe\nb-mermaid_56b617d41ad946938db0aa835dcc72a4\setup.py", line 33, in <module>
cmdclass=cmdclass(
File "D:\Python\Python39\Lib\site-packages\jupyterpip\__init__.py", line 60, in cmdclass
from IPython.html.nbextensions import install_nbextension
File "D:\Python\Python39\Lib\site-packages\IPython\__init__.py", line 49, in <module>
from .terminal.embed import embed
File "D:\Python\Python39\Lib\site-packages\IPython\terminal\embed.py", line 19, in <module>
from IPython.terminal.ipapp import load_default_config
File "D:\Python\Python39\Lib\site-packages\IPython\terminal\ipapp.py", line 45, in <module>
from IPython.core.magics import ScriptMagics
File "D:\Python\Python39\Lib\site-packages\IPython\core\magics\__init__.py", line 22, in <module>
from .execution import ExecutionMagics
File "D:\Python\Python39\Lib\site-packages\IPython\core\magics\execution.py", line 45, in <module>
from IPython.utils.timing import clock, clock2
File "D:\Python\Python39\Lib\site-packages\IPython\utils\timing.py", line 64, in <module>
clocku = clocks = clock = time.clock
AttributeError: module 'time' has no attribute 'clock'
----------------------------------------
WARNING: Discarding https://mirrors.aliyun.com/pypi/packages/b9/40/c721865ce3ce642a335b22cdc565586017636337eeab4a40e59ad27e2fd1/nb-mermaid-0.1.0.tar.gz#sha256=69da43b8e94f4ef394395baf68ca2abfd4563955bbb36171b7da48ece05869d1 (from https://mirrors.aliyun.com/pypi/simple/nb-mermaid/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement nb-mermaid (from versions: 0.1.0)
ERROR: No matching distribution found for nb-mermaid
WARNING: You are using pip version 21.2.4; however, version 23.2.1 is available.
You should consider upgrading via the 'D:\Python\Python39\python.exe -m pip install --upgrade pip' command.
我试着给 Jupyter 安装扩展,但是没有找到 Mermaid 扩展选项。
我需要帮助!有人知道如何在 Jupyter 上使用 Mermaid 吗?