Skip to content

Instantly share code, notes, and snippets.

@nafeesb
Last active March 30, 2024 06:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nafeesb/19a1d07fe35fb018d23779fe7c8865e5 to your computer and use it in GitHub Desktop.
Save nafeesb/19a1d07fe35fb018d23779fe7c8865e5 to your computer and use it in GitHub Desktop.
Maya python interactive debugging with Visual Studio Code

From: http://iwonderwhatjoeisworkingon.blogspot.com/2017/04/debugging-maya-using-visual-studio-code.html

  1. Install ptvsd
pip install --user ptvsd
  1. Start ptvsd server in Maya
import ptvsd
ptvsd.enable_attach(address=('0.0.0.0', 3000), redirect_output=True)
  1. VSCode debug config
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Remote Attach",
            "type": "python",
            "request": "attach",
            "port": 3000,
            "host": "localhost",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "${workspaceFolder}"
                }
            ]
        }
    ]
}
  1. Start debugging
  2. Set break point
  3. Execute code in Maya
@zhalice2011
Copy link

Thank you for your tutorial. Standing on your shoulders, I have developed a VS Code extension to simplify the debugging process.

To debug Python code in Maya 2022 or above using VS Code, you can use the "Debugger for Maya" extension available here:
Debugger for Maya

For guidance on how to use it, check out this video tutorial:
Video Tutorial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment