I think PyScript should come out with an IDE plugin first to make coding easy.

At present, I use pycharm to open the HTML document for editing, and then it is very inefficient to write python code in it, because I need to enter the code completely manually, and the IDE will not prompt any PYTHON code.

Hello, and welcome to the forum!

It’s true, the limited tooling for writing Python inside of HTML is unfortunate at the moment. While there’s been some possibility of improvement discussed from both VSCode and PyCharm, at the moment I think the best option is to use the src attribute of the PyScript tag to locate the code in a separate file.

So your py-script tag becomes: <py-script src="my_code.py"></py-script>, and your Python code lives in my_code.py, where hopefully PyCharm (or another IDE) will recognize it and give you autocompletion etc.

It’s worth noting - the src parameter takes a url, not a file path, so the files do not need to be fetched .

Hi Jeff,
Is it possible to debug your python script in the VSCode IDE if your py file is loaded as an url in ‘src’ ?

1 Like

Not currently, no - there’s not a mechanism to hoist the breakpoints set in VSCode into the Browser/Interpreter that’s running Python/PyScript.

That said, there’s been quite a bit of discussion around native Python debugging in Pyodide - see this GitHub Issue, for example.

Hi Jeff,
and thanks for this good link !

François-Régis

1 Like