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:
  1. Download and install Microsoft's free Visual Studio Code
  2. Install the official Python Extension 
  3. Extract the ptvsd folder into your Maya scripts folder
  4. Open Maya and run
    import ptvsd
    ptvsd.enable_attach("my_secret", address = ('0.0.0.0', 3000))
  5. Back in VSC, switch to Attach (remote debug) in the debug configurations and start it

    The editor should now look something like this
  6. You are now ready to debug. 
Note: here is the settings I use in launch.json



Add break points, run your code and it should stop and populate the debug section of Visual Studio code when it hits a break point

Comments

  1. My breakpoints are grey/ignored. Do you know of a way to fix this?

    ReplyDelete
  2. I think your break point is disabled, right-click on it and select "Enable Breakpoint"

    ReplyDelete
    Replies
    1. Hi Joe, thanks for your reply.
      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

      Delete
  3. Same for me, my break point are iognored, can you make a video about this.
    It could be really helpfull

    ReplyDelete
  4. What settings do you guys use for the launch.json?
    I've just updated the post with my settings, give them a go and let me know if it works

    ReplyDelete
  5. Hi,

    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".

    https://imgur.com/a/XltBC

    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 :/ ?

    ReplyDelete

Post a Comment

Popular posts from this blog

Expressions in JSE!

Early Butterfly flock using nParticles and instancing