Cannot debug my Python add-in

Just wrote an article on how to debug your Python script/add-in

One thing missing from it is about what to do if the compiler runs into problems with the main module (vs an additional module your code is loading).
In that case, checking "Raised Exceptions" in the "Breakpoints" section is not enough 🙁
Your code will fail silently and the debug process won't start

You can work around that by running Python compile on your main module/main Python file to find out what the problem is with it.

Once you started debugging your code from Fusion 360 and ended up in VS Code, you can follow these steps:

1) Open up the Terminal in VS Code (View >> Terminal)

2) Open the .vscodesettings.json file of your add-in – this will have the path to the Python version that Fusion 360 is using

3) Copy the full path set for "python.pythonPath" into the terminal

4) Add "-m py_compile" to the text in the Terminal window

5) Drag&drop your Python file's tab into the Terminal – that will copy/paste the full path of that file in the Terminal

6) Now just hit enter in the Terminal and that should run the Python compiler, which should list the first error the compiler runs into 

DebugPython1

Let's compare the error and our Python file:

DebugPython2

In this case, the error message is not the clearest, but at least we have something to go on 🙂
Solution to this specific error is here: Issues with migrating to Python 3.7.3


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading