Maya remote debug with VSCode

195 views
Skip to first unread message

Mengjing Yang

unread,
Jan 26, 2023, 5:27:58 PM1/26/23
to Python Programming for Autodesk Maya
Hello guys,

I'm learning how to remote debug using VSCode, but got error message when trying to create a polyCube.
debugFail.jpg

These are what I've done:
1.download and unzip debugpy in maya scripts folder
2.run following code in maya script editor
debugFail2.jpg
3.set maya python debugger in VSCode launch.json 
debugFail3.jpg
4.start debugging

Anyone notice anything I'm missing here?
Thanks a lot in advance~

Mengjing Yang

unread,
Jan 26, 2023, 5:32:53 PM1/26/23
to Python Programming for Autodesk Maya
Just realized that the second snapshot is too small...
Here is the code that I put:
import sys
import os
#os.path.expanduser("~") expands to the User's documents folder when used inside Maya, but expands to the user's root folder when run in a CPython installation.
sys.path.append(os.path.abspath(fr'{os.path.expanduser("~")}\..\.vscode\extensions\ms-python.python-2022.20.2\pythonFiles\lib\python'))

import debugpy
#overwrite the default python executabledebugpy.breakpoint()

maya_location = os.path.join(os.environ.get("MAYA_LOCATION"), "bin", "mayapy.exe")
debugpy.configure({'python': maya_location})

# 5678 is the default attach port in the VS Code debug configurations. Unless a host and port are specified, host defaults to 127.0.0.1
debugpy.listen(5678)
print("Waiting for debugger attach")
debugpy.wait_for_client()
print('break on this line')


Reply all
Reply to author
Forward
0 new messages