visual-studio-codejupyter-notebookplantuml

Syntax error when trying to use "iplantuml" in Jupyter Notebook


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

pip install iplantuml

import iplantuml
%%plantuml

@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml

Keep getting this error:

Cell In[3], line 5
    Alice -> Bob: Authentication Request
    ^
SyntaxError: invalid syntax

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

What am I missing?


Solution

  • The %%plantuml magic command should be the first line in its cell.

    Here's how you could structure your cells:

    # Cell 1
    !pip install iplantuml
    
    # Cell 2
    import iplantuml
    
    # Cell 3
    %%plantuml
    @startuml
    Alice -> Bob: Authentication Request
    Bob --> Alice: Authentication Response
    @enduml