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

Post a Comment

Popular posts from this blog

Early Butterfly flock using nParticles and instancing

Expressions in JSE!