Debugging Maya tools with PyCharm 2020.1

If you’ve been working with Maya tooling and PyCharm for a couple years you will have noticed that MayaCharm is not being updated as often as before. I’ve had to stick to quite old versions of PyCharm to even install MayaCharm, let alone run the remote debugging but that time is now gone. Everytime I have a new computer it is a big pain to set this up and running and recently I can’t get anything working!

I’m running PyCharm 2020.1 and MayaCharm is not compatible with that. Installing from disk will give you an incompatibility error.

I tried setting up debugging with the Python Debug Server and pydevd and it doesn’t work either.

How is everyone else doing with this? I don’t wanna use Eclipse but if you can’t even hookup the damn remote debugger to Maya then PyCharm is completely useless!

EDIT:
I’ve tried rolling back to earlier versions of PyCharm (going as far back as 2018.3) - and earlier versions of MayaCharm (as far back as 2.1) and no matter what, the MayaCharm Debugger never shows up in my run configs.

@passerby Can probably answer some of this better than not.
But I think it comes down to a lack of time, some changes on JetBrains side, and not using Maya as much as he used to in the past.

Yeah bob is on the point, i am a lot busier lately and no longer use Maya for work. Combine that with changes to newer PyCharm versions that broke things its hard to find the time to work on it and try and work around these new problems.

Though some of what you are mentioning might just be confusion of how a feature works. The latest released version of the plugin should run fine on PyCharm 2019.2 or lower.

Debug attaching is no longer part of the run config, but if you open Run and select Attach to Process... while the plugin is installed and you have Maya properly setup in the plugins settings. Running Maya instances will show up as possible targets to attach the debugger too. once its attached you can carry on and use the run config to execute code in Maya or do what ever you need to.

Edit:
Have not made progress recently, but my GitHub is the best place to track any progress to the >= 2019.3 support

@Nightshade I’m happy to see @passerby has been making progress on the MayaCharm repo for this. MayaCharm is definitely the ideal solution for remote debugging with PyCharm. You mentioned you were having some trouble configuring it manually, so I wanted to offer as a stop-gap a blog post that I wrote for how to configure remote debugging manually without “attach to process”: https://matiascodesal.com/blog/how-to-use-pycharms-remote-debugging-with-maya/

1 Like

Thanks for writing this guide.
Unfortunately I end up with this:

Waiting for process connection…
import pydevd_pycharm
pydevd_pycharm.settrace(‘localhost’, port=9001, stdoutToServer=True, stderrToServer=True, suspend=False)
Connected to pydev debugger (build 211.5538.22)
Warning: wrong debugger version. Use pycharm-debugger.egg from PyCharm installation folder
Or execute: pip install pydevd-pycharm~=%{0}

EDIT:
I had to do some changes

  1. I removed my path mappings. Reason is that I already have a symbolic link (junction) between the git repository and the Maya user script directory.
  2. I had to change pydevd to pydevd_pycharm. So the import, stoptrace() and settrace() all run pydevd_pycharm.

Also worth mentioning to others setting this up:

  1. You could setup the pydevd_pycharm -method as a decorator
  2. Symbolic link (junction) works just as well as path mappings
  3. When you click the debug icon you also need to trigger stuff in Maya. Go into your tool - or the script editor - and execute the function where you have the breakpoints and the debugger -code.

EDIT2:
Apparently you can use either. The warning message in PyCharm is just that - a warning. I had some issues with this working a 2nd/n:th try but solved that by just removing my tool’s modules from sys.modules and hitting the stop button in PyCharm and running again.

Also, any ideas as to why Maya keeps being suspended even after hitting the Debug stop button?

Glad the guide help you stick with PyCharm :slight_smile:
Sounds like you worked out the first issue, but just to document the solution here:
To avoid the warning, the path to the pydev egg in the connection code needs to be the path to the same PyCharm version you’re running.

RE: pydevd vs pydevd_pycharm
From what I remember pydevd_pycharm is a minimal wrapper around pydevd so I just use pydevd directly in case I need access to the internals in the future.

RE: debug hang ups
I specifically add the stoptrace before settrace to clear out previous connections because I did have issues running subsequent debugs. That’s resolved any issues I had with remote debugging hang ups. If you’re using the same setup, I’m not sure what could be the cause.

Only done some minimal tests, but there is a 3.2.2 version of MayaCharm now as well that works in modern PyCharm versions. downside is that it does require the command port to run so has a bit of setup to use.

1 Like