Using Wing IDE with Maya

by Nicholas Stevenson

Hey Everyone,  I created this post because I have found that using an external IDE and Debugger with Maya to be one of the best investments I have ever made.  With this post, I hope to explain a lot of the technical details, and hopefully enough to get you up and running!

What is an IDE?

This question has been answered many times before, but to quickly summarize, an IDE is simply a programming environment for use in scripting and programming.  Maya’s script editor is a basic example of an IDE.  More full featured IDE tools, such as Wing IDE, fulfill all of the basic functions that Maya’s script editor offers, as well as incorporating many additional features.  

What is a Debugger?

A debugger is simply an extension to an IDE.  An IDE with a built in debugger allows you to not only code in a more friendly environment, but to also evaluate your code while it’s being executed, making larger scripts and programs worlds easier to create.

Getting Started with Wing

This section is going to cover how you can configure Wing to completely replace the need for the Script Editor in Maya.  Allowing you to use Wing as your default Python tool, debug your code, and execute your code remotely in Maya while inside Wing.

Note: Wingware provides a step by step, explaning many of these same points, but I am going to expand a bit beyond where their instructions leave off.  

http://wingware.com/doc/howtos/maya

Downloading and Installing Wing

The first step is to download Wing, visit their web site and download your appropriate version:

http://wingware.com/

Copy Wing's Debug Module to Maya's Script Path

After installing Wing, take Wing's Python debugger module located here: C:\Program Files (x86)\Wing IDE 4.1\wingstub.py

and place it in a more appropriate location: (Eg. C:\Users\[your user name]\Documents\maya\scripts\)


Also, alter line 96 inside the wingstub.py file:

To explain, kEmbedded tells Wing if this specific python instance fires one and then ends itself, or if it's a persistent python environment.  In Maya's case, the environment doesn't close itself down after it is done executing a python asset.

kEmbedded = 0

To​

kEmbedded = 1

Connecting Maya to Wing

Once back in Maya, create a shelf button containing this Python code:

import wingdbstub
wingdbstub.Ensure()

Note: As long as you saved the wingdbstub.py file in to the \Documents\maya\scripts\ directory, Maya should be able to find the module.

If you chose a different directory, you will have to tell Maya's Python environment this new location. Python only looks in a limited number of places when looking for modules to load. The following code can be used to add an additional directory.

import sys

path_append = 'E:/Dropbox/Scripting/Maya'
if path_append not in sys.path: sys.path.append(path_append)

You can also create a python file named userSetup.py, that contains only this code, and place it inside you /Documents/Maya/Scripts/​ directory, and this path will be added every time you start Maya.  Maya will execute and userSetup.py file that it finds in its script directories, so it's a great way to permanently add a path to Maya's Python Environment.

Setting up Wing for the connection

Once you have added your shelf code, launch Wing.  Once inside Wing, in the very bottom left corner, you should see a small bug icon.  Left click on it and ensure that 'Enable Passive Listen' is checked.

wingDebugIcon2.jpg

Run your shelf button

If you have everything configured correctly, you should hopefully see your Wing IDE Debugger icon turn a lovely green.

wingDebugIcon3.jpg

Once you have established this connection, Wing can now be used to debug your own scripts and modules, and in particular, intercept any errors Maya may encounter while running Python code.  This last point is incredibly useful when tracking down errors in your code.

This is pretty much it, in my next post, I'll go over how to remotely send commands from Wing in to Maya.  

I use this program all day, every day, and it is a great application to use with Maya.