pythonvisual-studio-codejupyter-notebookplantuml

Unable to generate plantuml diagram when trying to use "iplantuml" in Jupyter Notebook within vscode


I'm trying to use iplantuml in jupyter notebook within VS Code.

enter image description here

Keep getting this error:

---------------------------------------------------------------------------
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

If I hover over the import iplantuml I see this error:

"iplantuml" is not accessed Pylance

I can generate a plot using matplotlib. It is only plantuml I'm unable to use

I tried doing an extra step below but then I ran into another issue of module not found and pip install didn't resolve it either. Also, didn't have to do this when I was using jupyter notebook within anaconda

   %load_ext plantuml_magics

I What am I missing?


Solution

  • From your screenshot, it seems that your first cell was never executed because it's showing empty squared brackets [ ] without any number inside.

    Try to run it.

    I tried your code using a virtualenv (named "so") and it works fine.
    You can see/set which python interpreter ("kernel") to use like so : enter image description here

    VSCode might warn you that the virtualenv doesn't have ipykernel installed : enter image description here

    Install it.

    If everything goes well (restart the kernel after installing packages) : enter image description here