-
Get PyCharm. (Pro required or does free version now support Maya Debugging?)
-
Setup a PyCharm project to use the Maya Interpreter (File > Settings > Project Interpreter).
-
Add a Remote Debugging Configuration: Run > Edit Configurations
- Add > Python Remote Debug
- Name Configuration
- Check "Single instance only" ON
- Set the port (i.e 7720)
- Uncheck both “Redirect to console Input” and ”Suspend after connect”.
-
In PyCharm add a break point somewhere and press debug. A progress indicator and "Waiting for connection" shows near the bottom and prints to debug console.
-
Ensure PyCharm debug is on Maya's Python path, one way is with a Maya startup script:
# <UserDocs>\maya\2016\prefs\scripts\userSetup.py
import sys
sys.path.append('C:\Program Files (x86)\JetBrains\PyCharm 5.0.2\debug-eggs\pycharm-debug.egg')
- Connect Maya to the PyCharm debug server using the same port from configuration. PyCharm's "waiting connection" should hide and "Connected to pydev debugger..." prints in debug console.
# Inside Maya Python Console (Tip: add to a shelf button for quick access)
import pydevd
pydevd.settrace('localhost', port=7720, suspend=False)
# To disconnect run:
# pydevd.stoptrace()