在vscode中的Jupyter Notebook使用"iplantuml"时无法生成plantuml图表

0 投票
1 回答
58 浏览
提问于 2025-04-13 01:36

我在VS Code里用Jupyter Notebook想要使用iplantuml这个库。

这里插入图片描述

但是我一直遇到这个错误:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[10], line 1
----> 1 get_ipython().run_cell_magic('plantuml', '', '@startuml\nAlice -> Bob: Authentication Request\nBob --> Alice: Authentication Response\n@enduml\n')

File ~\AppData\Roaming\Python\Python312\site-packages\IPython\core\interactiveshell.py:2541, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
   2539 with self.builtin_trap:
   2540     args = (magic_arg_s, cell)
-> 2541     result = fn(*args, **kwargs)
   2543 # The code below prevents the output from being displayed
   2544 # when using magics with decorator @output_can_be_silenced
   2545 # when the last Python token in the expression is a ';'.
   2546 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File c:\Users\....\AppData\Local\Programs\Python\Python312\Lib\site-packages\iplantuml\__init__.py:101, in plantuml(line, cell)
     99 output = None
    100 if use_web:
--> 101     output = plantuml_web(uml_path)
    102 else:
    103     plantuml_path = os.path.abspath(args.plantuml_path or PLANTUMLPATH)

File c:\Users\.....\AppData\Local\Programs\Python\Python312\Lib\site-packages\iplantuml\__init__.py:68, in plantuml_web(*file_names, **kwargs)
     57 """
     58 Given a list of UML documents, generate corresponding SVG diagrams, using
     59 PlantUML's web service via the plantweb module.
...
   1553     self._close_pipe_fds(p2cread, p2cwrite,
   1554                          c2pread, c2pwrite,
   1555                          errread, errwrite)

FileNotFoundError: [WinError 2] The system cannot find the file specified

当我把鼠标放在import iplantuml上时,看到这个错误:

“iplantuml”没有被Pylance访问

我可以用matplotlib生成图表,但就是无法使用plantuml。

我尝试做了下面的额外步骤,但又遇到了找不到模块的问题,使用pip安装也没有解决这个问题。而且在使用Anaconda里的Jupyter Notebook时,我并不需要这样做。

   %load_ext plantuml_magics

我到底漏掉了什么呢?

1 个回答

暂无回答

撰写回答