Wing/Maya Remote Debug Setup

Categories: IDE, Maya, Python
Comments: 12 Comments
Published on: March 28, 2011

There are some great posts and pages explaining how to setup Wing IDE to remotely debug a Maya session. Eric Pavey first posted how to do this at his WarpCat Blog along with how to send commands back and forth to Maya from Wing.

Luckily, now, many of us are starting to use this workflow and some other little tips and tricks have been discovered. I’d like to spell out all the steps from beginning to end right here.

  1. Hack wingdbstub.py
  2. Adjust Remote Debugging preferences in Wing
  3. Create method to connect to Wing from Maya
  4. Add pythonpath to module

In detail . . .

1. Hack wingdbstub.py

Copy wingdbstub.py from your:

C:/Program Files (x86)/Wing IDE 4.0/.

and put it into your favorite pythonpath folder with the rest of your development code.

Change the lines:

(~ line 96)

kEmbedded = 0

to

kEmbedded = 1

and maker sure this line points to your actual installation dir of wing:

(~ line 116)

WINGHOME = r"C:\Program Files (x86)\Wing IDE 4.0"

for OSX:

WINGHOME = r"/Applications/wingIDE/WingIDE.app/Contents/MacOS"

2. Adjust Remote Debugging preference in Wing

In wing goto Edit -> Preferences -> Debugger -> External/Remote
Check:
‘Enable Passive Listen’
‘Kill Externally Launched’

Then right click on the bug icon in lower left of Wing’s window and make sure that Passive Listen is enabled

3. Create method to connect to Wing from Maya

Now, make a nice method which you can call from a hotkey in Maya. I’d make a method like this:

# developerTools.py
# make sure this method is in a module in your pythonpath

def connectToWing():
		"""
		SYNOPSIS
		 Connects to wingIDE debugger

		INPUTS NONE

		RETURNS: Nothing
		"""
		import wingdbstub
		try:
			wingdbstub.Ensure()
			print 'Connected to wingIDE'
		except ValueError:
			print 'Could NOT connect to wingIDE'

Now you can make a hotkey in Maya by adding this as the command in the hotkey editor (suggest CTRL+SHIFT+w):

// this is mel code because that is what hotkey editor recognizes
python("import developerTools");
python("reload (developerTools)");
python("developerTools.connectToWing()")

4. Add pythonpath to module

Make sure your the folders that your deverlopTools.py (or wherever you make the connectToWing module) and the folder to your wingdbstub.py are part of your pythonpath. If you ever need to see what pythonpaths your (Maya) environment is aware of, you can just try this:

# prints all pythonpaths

for p in sys.path: print p

Actually there are a bunch of handy paths to consider as a developer for Maya, but I’ll save that for next post. 😉

Now just:

  • start Wing
  • start Maya
  • call connectToWing() method (CTRL+SHIFT+w) (bug should turn green in Wing)
  • setup a breakpoint in code in Wing
  • call that code from Maya

And if you’re still having trouble, feel free to post questions/comments here or follow these links to my source documentation:

WingWare setup docs

MEL Wiki

Happy debugging!

Post to Twitter

12 Comments
  1. Jonas says:

    Jason, this is great. I’m really glad I didn’t spend time last week trying to set this up b/c this took minutes to do, whereas it might have taken me hours. For now, I’m having an issue with connectToWing(). Wing throws an error here:

    TypeError: StartDebug() got an unexpected keyword argument ‘autoquit’

    File “G:\Scripts\Maya\Python\EABL_DH2\developerTools.py”, line 22, in connectToWing
    wingdbstub.debugger.StartDebug(autoquit=False);

    • jparks says:

      Jonas,

      Go ahead and remove the keyword arg ‘autoquit=False’ from the StartDebug call. Should still work. You working in OSX by any chance? Trying to determine when this arg is needed and when it errors. I got that error at home on OSX when I had that keyword in the call as well.

  2. Jonas says:

    Nope, on win 7 -64 bit. I did remove the arg already and it works fine. I went over all of Wing’s debugger docs today to familiarize myself so I still need to test debugging one of my scripts but I believe I’m off to a very good start!

  3. Holy crap! I put this off for way too long. This and unittesting have just changed/saved my pipeline. Thanks for posting this! Goodbye Eclipse/Pydev!

    • jason says:

      I use both Wing and Eclipse/Pydev is a superior coding environment. Wing is better at debugging w/ the debug probe and has nice unitTest features. It seems a bit much, but using both is a very nice solution, actually.

  4. Nami says:

    Hi Jason!

    I tested today the debugging with Wing IDE and works fine!

    But, I see in your presentation one video where you write “joint(n=’test’)” and the joint is created in Maya instantly. I try to recreate the same example but the joint only is showed in Maya when the debug is finished. The Maya viewport doesn’t refresh when Wing IDE is in debug mode. How can I fix that?

    Thanks Jason! 🙂
    Nami

    • jason says:

      Nami,

      The refresh of the app while debugging is pretty finicky. It is not supposed to refresh at all. I think under certain conditions you can get the perspective view to redraw but I could never get the outliner to redraw. I do not remember exactly how I stumbled across how to do this, it was really more of a ‘bug’ rather than a feature. It may have been a Win7, thing.

  5. ParticlePeter says:

    Hi Jason,
    I have an issue with the presented setup. When an error is encountered in my python script, Maya is terminated. When I uncheck ‘Kill Externally Launched’, Maya is not terminated, but then I can’t fix the error ( with or without stopping the debugger ), save and restart the script from Maya. The only help google gave me was this outdated post:
    https://groups.google.com/forum/?fromgroups=#!topic/python_inside_maya/16ge9RAa_FA
    But it still does not help. Any Idea what I’m doing wrong ?

    Cheers, PP

    • jason says:

      Maya should not terminate on an error of course. I’m pretty sure you have to have ‘Kill Externally Launched’ to get any kind of connection. I’ve never run the debugger without that checked. But that is not the answer.

      Most people cannot connect, but I’ve never heard of your problem before. Many people have got this to work, so there must be something odd in your setup. I would suggest starting from scratch.

      I think WingWare even includes their own instructions on how to connect to Maya because it is so popular now. You may want to try their setup procedure: http://www.wingware.com/doc/howtos/maya

      You can always email them. I’ve found they’ve been very responsive and fixed anything I needed. If you find out what was wrong, please post here to let us know.

      -jason

  6. Padraig O Cuinn says:

    Im using maya 2015 and Wing 5.01

    Im having issues setting the entire process up 🙁

    • jason says:

      You’ll have to be more specific than that. There might be minor changes as all the softwares have updated since then.

      You may want to consider upgrading to PyCharm as it is a far superior product, however.

  7. jason says:

    Here’s a great plugin to help you do this:
    http://www.creativecrash.com/maya/downloads/applications/syntax-scripting/c/eclipse-maya-editor

    Christian’s post on Making Eclipse soar gives some more instructions to help with this setup:
    http://christianakesson.com/siteRoot/?p=3366
    Look under 3. -> Maya Connection

  1. […] http://www.jason-parks.com python ← How can I have Wing send Python or mel code to Maya? Leave a comment ?0 Comments. […]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Welcome , today is Wednesday, May 31, 2023