Debugging in Maya with debugpy and VSCode

Debugging your python code in Maya is particularly painful subject, for sure.

Proper debugging. With a debugger…

I’ve tried many times and gave up. Setting it all up and making it work is just way too much of a hassle. I know some people have made it work with pycharm but

  • a) I dont use pycharm and
  • b) I still think there are some issues there (more info here, here, and here).

This post is about vscode and for a long time a “go to” debugger was ptvsd. Here are quick instructions how to use it to debug python in maya: link and link.

However, Microsoft has since deprecated ptvsd in favor of debugpy. The way to use it is pretty much the same with minor difference in code that needs to be run so here it is (replicating Joseph Yu’s steps for comparison):

  1. Download and install Visual Studio Code
  2. Install the official Python Extension
  3. Grab the latest release of debugpy as a zip
  4. Extract scr/debugpy into documents/maya/scripts/debugpy
  5. Open Maya and run:
    import os
    import debugpy
    mayapy_exe = os.path.join(os.environ.get("MAYA_LOCATION"), "bin", "mayapy")
  6. Open your project in vscode and create launch.json (you can do this manually really):
  7. Open .vscode/launch.json and replace the default content with:
     "version": "0.2.0",
     "configurations": [
             "name": "Python Attach",
             "type": "python",
             "request": "attach",
             "port": 5678,
             "host": "",
  8. Click Start Debugging:

You may now place your breakpoints and call the code from Maya.