chialiyun / DiagramsPreviewerVSCExt

Visual Studio Code Extension to preview Diagrams (Diagram as a Code)
MIT License
6 stars 0 forks source link

Python not being identified. #14

Open gowthron opened 3 months ago

gowthron commented 3 months ago

Hi Folks,

I was looking to attempt to start using your plugin but I keep getting the error:

"Error executing the code, please make sure you have Python3 (3.6 or higher) with the relevant packages (diagrams) and Graphviz installed. You may refer to the Requirements section for more information."

I have Python 3.6 installed on my laptop and VS code has Graphviz / Diagrams Interpreter and Python plugins.

Python plugin has path the Python installed listed in the "Python: Default Interpreter Path". Diagrams plugin has the setting "Python Command: VS Code Python Interpreter".

Not sure what is going wrong here, any help would be appreciated.

Regards,

Ed.

nogara commented 3 months ago

I have a similar problem, but in my case I have Python and everything installed locally in a virtualenv. VS Code detects this and uses the right Python interpreter, with all the installed packages, but this plugin does not understand this for some reason.

nogara commented 3 months ago

From what I could understand from the source code, the extension parses the original diagram python file, tries to change the parameters of with Diagram(...) to include filename="previewDiagram", show=False and creates a new python file inside its docs directory.

In my case, this parse did not work, so the final python file has syntax errors. Since the error message is the same for any error during execution, this was masked by the error message you mentioned in the original post.

I'm using for now a simplified version of the plugin, in which I ignore this parse part and only copy the original file to the targetSrcFile. I made sure I put the right parameters in the original python file, so as to the plugin code to work.

I will take a look if I can help making the parser a little bit more robust than it is now, and I'll send a PR if I'm successful...

gowthron commented 3 months ago

Hey nogara,

I dug a bit deeper on this and I believe it may be tied to the version of Python - 3.6. The original error called for that as a minimum so I had that installed (Work laptop).

THe Python debugger plugin only works with vesion 3.7 or greater. I am waiting for a 3.11 install and will test again.

I would be interested to know where the only Diagrams Previewer setting and value for windows of: VS Code Python Interpreter pulls the Python version for it - The Python plugin or the debugger. If it is the debugger, the version I am using may be the issue.