Debugging Maya using Visual Studio Code
I've been testing debugging Maya Python scripts lately. Mostly focusing on free IDEs or editors such as PyCharm. So far this is one requires less setup in my opinion.
This is mostly based off the remote python debugging functionality described here:
- Download and install Microsoft's free Visual Studio Code
- Install the official Python Extension
- Download ptvsd package as a zip
- Extract the ptvsd folder into your Maya scripts folder
- Open Maya and run (updated! Thanks Luciana!)import ptvsdptvsd.enable_attach(address=('0.0.0.0', 3000), redirect_output=True)
- Back in VSC, switch to Attach (remote debug) in the debug configurations and start it
The editor should now look something like this
- You are now ready to debug.
Note: here is the settings I use in launch.json
My breakpoints are grey/ignored. Do you know of a way to fix this?ReplyDelete
I think your break point is disabled, right-click on it and select "Enable Breakpoint"ReplyDelete
Hi Joe, thanks for your reply.Delete
No I don't think the breakpoint is disabled, it is coming up as unverified. Perhaps the connection process is not completing, I cannot see any output in the vs code window
Same for me, my break point are iognored, can you make a video about this.ReplyDelete
It could be really helpfull
What settings do you guys use for the launch.json?ReplyDelete
I've just updated the post with my settings, give them a go and let me know if it works
What you describe in your article seems really promising, but unfortunatly, I've got the same problem : my breakpoint are greyed out and it is written "Unverified Breakpoint".
Here is my launch.json : https://imgur.com/a/O5L9C
I'm using VSCode 1.16.0 and pythonVSCode 0.7.0.
I tried to disable all my other plugins with both 32 and 64 bits versions of vscode but nothing worked.
It seems that other people already had this problem as you can see on github https://github.com/DonJayamanne/pythonVSCode/issues/690 but there was no solution to it.
Any ideas :/ ?
I'm very late to the party here but others might stumble upon this page.Delete
The visual studio code Documentation states that you need ptvsd 3.0.0 and exactly this version.
installing it worked perfectly for me!
Remote debugging no longer supports the 'secret' field (see here: https://github.com/Microsoft/vscode-docs/issues/1794). So step 5 should be edited to: ptvsd.enable_attach((address = ('0.0.0.0', 3000), redirect_output=True)ReplyDelete
Awesome, thanks for letting me know!Delete
It might be a good idea to direct people to the downloads page for ptvsd and call out downloading the latest. I'm assuming VSCode updates to have the latest and the versions need to be the same. Initially I had trouble getting things working not realizing 3.0.0 wasn't the latest but nothing errored, it just didn't go into debug mode.ReplyDelete
I tried setting it up with Maya 2017 extension5, pvsd 4.2.10, vscode still can't hit the breakpoint.
I'm getting all the std output, list of threads in call stack, but when I type "import maya" I get
Unable to find thread for evaluation.
Anyone knows how to deal with this?