asciidoctor / asciidoctor-intellij-plugin

AsciiDoc plugin for products on the IntelliJ platform (IDEA, RubyMine, etc)
https://intellij-asciidoc-plugin.ahus1.de/
Apache License 2.0
357 stars 146 forks source link

ModuleNotFoundError: No module named 'diagrams' #759

Closed sindre-nistad closed 3 years ago

sindre-nistad commented 3 years ago

Observed vs. expected behavior

When using the new diagrams diagram is supported, I'd like ut use it in the IntelliJ plugin as well.

However, when I try to recreate this example, I get an error saying that the diagrams module cannot be found.

Is there a way to set which Python interpreter the plugin uses?

Steps to reproduce

example.adoc

[diagrams, format=svg]
----
from diagrams import Diagram
from diagrams.aws.compute import EC2
from diagrams.aws.database import RDS
from diagrams.aws.network import ELB

with Diagram("Grouped Workers", show=False, direction="TB"):
    ELB("lb") >> [EC2("worker1"),
                  EC2("worker2"),
                  EC2("worker3"),
                  EC2("worker4"),
                  EC2("worker5")] >> RDS("events")
----

Rendered in IntelliJ

Failed to generate image: python3 failed: Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'diagrams'

from diagrams import Diagram
from diagrams.aws.compute import EC2
from diagrams.aws.database import RDS
from diagrams.aws.network import ELB

with Diagram("Grouped Workers", show=False, direction="TB"):
    ELB("lb") >> [EC2("worker1"),
                  EC2("worker2"),
                  EC2("worker3"),
                  EC2("worker4"),
                  EC2("worker5")] >> RDS("events")

Environment

Plugin Version: 0.32.47

IntelliJ Details: PyCharm 2021.1.1 (Professional Edition) Build #PY-211.7142.13, built on April 21, 2021 Licensed to Bouvet Norge AS / Sindre Nistad Subscription is active until October 31, 2021. Runtime version: 11.0.10+9-b1341.41 x86_64 VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o. macOS 11.3.1 GC: G1 Young Generation, G1 Old Generation Memory: 4096M Cores: 16 Registry: bigger.font.in.project.view=true, localHistory.daysToKeep=365, ide.balloon.shadow.size=0 Non-Bundled Plugins: Dummy Text Generator (1.2.0), HtmlEntity (1.1), Key Promoter X (2021.1.1), Quick Notes (3.3), QuickJump (4.3), Statistic (4.1.7), YAML/Ansible support (0.11.2), awesome.console (0.1337.11), com.alayouni.ansiHighlight (1.2.4), com.arcticicestudio.nord.jetbrains (0.13.0), com.fernandojimenez.obsidian.theme (3.0.0), com.fwdekker.randomness (2.7.0), com.github.camork.fileExpander (1.6), com.github.leomillon.uuidgenerator (4.3.2), com.github.novotnyr.jwt-intellij-plugin (0.11), com.godwin.json.parser (1.4.1), com.intellij.ideolog (203.0.27.0), String Manipulation (8.15.203.000.3), com.jetbrains.CyanTheme (1.2), com.jetbrains.darkPurpleTheme (1.2), com.jetbrains.grayTheme (1.2), org.intellij.plugins.postcss (211.6693.64), com.kstenschke.copypastestack (1.1.5), com.mallowigi (36.0), com.mnr.java.intellij.idea.plugin.base64helper (2.0.3), com.thvardhan.gradianto (4.4), com.tobszarny.activetabhighlighter.plugin.id (1.4.0), com.ultrahob.zerolength.plugin (0.93), dev.meanmail.plugin.nginx-intellij-plugin (2021.2-211), ideanginx9 (0.1.9), in.thekalinga.snippet.intellij (6.1.0), indent-rainbow.indent-rainbow (1.6.1), io.github.qeesung.component.HighlightBracketPair (1.1.2), io.snyk.snyk-intellij-plugin (2.1.4), krasa.CpuUsageIndicator (1.14), mac-native (1.0), net.seesharpsoft.intellij.plugins.csv (2.16.3), net.vektah.codeglance (1.5.4), org.intellij.plugins.hcl (0.7.10), zielu.gittoolbox (203.5.8), mobi.hsz.idea.gitignore (4.1.0), name.kropp.intellij.makefile (211.6693.108), org.semonte.intellij.swagger (1.0.32), org.sonarlint.idea (4.16.0.31683), org.toml.lang (0.2.147.3871-211), pl.szymonprz.idea-cheatsh-plugin (1.3.2), socrates.tabshifter (0.30), com.intellij.plugin.adernov.powershell (2.0.6), com.vladsch.idea.multimarkdown (3.0.202.112), ImportCost (1.0.7.211), NodeJS (211.7036.9), org.jetbrains.plugins.node-remote-interpreter (211.6693.65), com.intellij.plugins.html.instantEditing (211.6693.111), spy-js (211.6693.78), Karma (211.6693.111), com.deadlock.scsyntax (211.6693.111), com.jetbrains.lang.ejs (211.6693.65), com.jetbrains.plugins.jade (211.6693.65), intellij.prettierJS (211.7142.13), org.jetbrains.plugins.vue (211.7142.13), lermitage.intellij.extra.icons (1.54.0.201), com.chrisrm.idea.MaterialThemeUI (6.5.0), com.github.mturlo.intellij.theme.spacegray (1.4.1), com.dmarcotte.handlebars (211.6693.44), com.intellij.lang.jsgraphql (2.9.1), com.intellij.swagger (211.7142.14), izhangzhihao.rainbow.brackets (6.17), PlantUML integration (5.3.0), com.dropbox.plugins.mypy_plugin (0.3.2), com.koxudaxi.poetry (1.1.4), com.koxudaxi.pydantic (0.3.2), org.tonybaloney.security.pycharm-security (1.24.1), com.jetbrains.edu (2021.4-2021.1-582), de.endrullis.idea.postfixtemplates (2.12.0.211), net.ashald.envfile (3.2.1), org.exbin.deltahex.intellij (0.2.4), ru.adelf.idea.dotenv (2021.1), ru.meanmail.plugin.requirements (2021.4-211), org.asciidoctor.intellij.asciidoc (0.32.47)

ahus1 commented 3 years ago

I haven't used this diagrams myself so far, but looking at the installation guide and the error message, "diagrams" needs to be installed first. The installation guide provides three examples, depending on your environment:

# using pip (pip3)
$ pip install diagrams

# using pipenv
$ pipenv install diagrams

# using poetry
$ poetry add diagrams

Please note that python is executed from the IDE, therefore it uses the IDE's path.

Looking at the docs, you can specify an attribute diagrams-python to select a specific python installation to use. This might help in your case. You can specify attributes either in the document, or in the plugin's settings in the IDE. In this case I would recommend the second option, as it is specific to the local setup.

Please let me know if this works for you.

ahus1 commented 3 years ago

There hasn't been a comment for about two weeks, therfore I close this issue for now. If more questions arise, please comment here and I'll re-open the issue.