This project has moved and is read-only. For the latest updates, please go here.

Maya debug method

Nov 3, 2014 at 4:28 PM
Edited Nov 3, 2014 at 4:29 PM
Win7x64 + Maya2015SP5Ext1 + VS2012+PTVS2.1


I spent whole day trying make PTVS debugging works with Maya 2015 and still it didn't work.
As shown in this video
i copied ptvsd from
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.1\ptvsd
C:\Users\<username>\Documents\Visual Studio 2012\Projects\SCRIPT\SCRIPT\ptvsd
and VS still didn't see ptvsd
So i tried to Add Environment (this thread But it didn't work as well.
Can you please provide the way to make remote debugging works with Maya ?
I'm already tried pyCharm and Eclipse and debug work well and with no problems in this IDEs.
Nov 3, 2014 at 4:48 PM
Nov 3, 2014 at 9:15 PM
Edited Nov 3, 2014 at 9:15 PM
And there is no information about solving ptsd error i've described earlier.
So if we find out how this error can be solved we can move farther.
Nov 3, 2014 at 9:20 PM
To clarify - is your own .py file located in "C:\Users\<username>\Documents\Visual Studio 2012\Projects\SCRIPT\SCRIPT"?

Also, note that the error that you're seeing is actually Intellisense warning indicating that VS couldn't locate the package. It won't preclude you from actually running your code, and it will run successfully if all the paths are right.
Nov 4, 2014 at 5:52 AM
Edited Nov 4, 2014 at 6:01 AM
Ok. So let's walk thru it step by step:
And there is no firewalls etc on my Notebook
Nov 4, 2014 at 5:59 PM
Hm, this is something new. It looks like the attempt to open the server socket was blocked.

Could it be that Maya itself blocks it for security reasons, by e.g. running those scripts in a sandbox? And it could be something specific to the new version of Maya.

First of all, I'd try experimenting with the endpoint. The default is, which would make the socket accessible on all external interfaces. Try changing it to something more restrictive, and maybe a different port as well, just in case, e.g.:
ptvsd.enable_attach(secret=None, address=('', 9999))
If that still doesn't work, then I would try it with a simplified repro - just create and bind your own socket directly:
import socket
server = socket.socket()
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(('', 9999))
If you still get the same error with the above code snippet (which you should), you can then forward it to Maya support and ask them why it is not working, and if it's indeed some kind of sandbox, whether there's any configurable way to disable it.

(If you create a follow-up discussion on their forums, can you please cross-reference it here with a link so that other people who find this topic can see the other one as well?)
Nov 6, 2014 at 7:56 AM
Edited Nov 6, 2014 at 8:05 AM
Thank you Pavel. We have progress.
Now i can attach to remote process but i can't understand why it didn't stop on breakpoints.
Another words when i connect to maya the script is already done.
Here is the steps i made:
By the way script is external file. I just open it in VS2012. It is not in Project.
Can this somehow cause VS to skip breakpoints ?
Nov 6, 2014 at 8:21 AM
enable_attach starts the debugging server on the background thread, but continues execution from there. If Maya unloads the interpreter instance after running the script, the debugging server will also go away.

Try adding ptvsd.wait_for_attach() right after enable_attach - this will block script execution until you actually attach.
Nov 6, 2014 at 8:22 AM
By the way, since it sounds like you figured out why it couldn't bind to the socket, can you share the solution to that problem here, so that other people running into it can find it?
Nov 6, 2014 at 11:32 AM
Unfortunately, Pavel, i didn't figured out why exactly Maya didn't bind socket last time.
When i start this thread, i reboot my Notebook a couple times and still it have socket error.
Tomorrow i just tried the same script and it just works. And with ptsd.wait_for attach(), breakpoints works as well.
Thank you so much for the speedy reply and help.
Nov 6, 2014 at 4:15 PM
Great to hear that it's working for you!
Nov 8, 2014 at 8:33 AM
By the way Pavel, can we solve intellisense error that i have ?
And is there any other way to make PTVS highlight same identifiers when they
selected ( ?
Nov 8, 2014 at 8:46 AM
Is it just ptvsd, or is it a general problem with one module importing another module in your project?

One thing you might want to do is make sure that your project's home path (in project property) is set properly to reference the folder where your script and ptvsd both are.

As for #129, the only way to make PTVS do it is to implement the feature. We don't have a definitive plan yet, but given how many votes it has, it is likely to end up on the todo list for the next release.
Nov 8, 2014 at 1:38 PM
Edited Nov 8, 2014 at 1:41 PM
Well, problem is:
CTRL+SPACE didn't show completions for imported module maya.cmds which is a Autodesk Maya main module.
But for ptvsd and default VS or System modules like "math" etc it works.
Maybe the problem is in the PROJECT settings or environment ?
There were previously created completionDB but completion for maya.cmds didn't work either.
So i delete environment variable.
Nov 9, 2014 at 12:38 AM
If I remember correctly, Maya puts its entire Lib folder in a zip file, and we don't know how to handle that (yet) - see:

If that's the case for 2015, as well, I would suggest unpacking that entire .zip, including Maya modules, and then adding it as a custom environment.

One other thing of note is that some of those modules are probably native modules written in C. Since type inference engine can't work on them like it does on pure Python code, it tries to parse docstrings for type information instead - so the quality of completions for such modules depends on the quality of their docstrings. As there's no uniform standard for documenting types that way, we try to be flexible to adapt to a wide range of approaches (covering e.g. PyQt and numpy), but occasionally we run into a binary module which uses some scheme that's different enough that our heuristics don't work. If this is what you're running into, file a bug on those specific modules that don't get completions, and it would also help if you can provide some of their docstrings.