Debugging Godot Python with PyCharm

Stan Prokop
3 min readApr 15, 2018

--

Recently I have found that Godot game engine has unofficial Python support. The project is still young, it does not support game export and you can find annoying things here and there, but it’s worth to follow.

However when I played with Godot Python, I was extremely missing support for visual debugging.

I do know that Python has a powerful builtin debugger pdb (I actually prefer ipdb), but compared to productivity gain I get from PyCharm’s visual debugger? I gladly forget command line and putting this pdb snippet everywhere into my project:

import pdb; pdb.set_trace()

Anyway, I have found a way how to do it. It wasn’t as trivial as I hoped (the first step required some digging), but with this guide it should be.

Godot setup

The first step took me some time to figure out. When I tried to use attach to local process, my process did not show up. So originally I thought that PyCharm does not support anything that embeds a Python interpreter - by that I mean it does not use an executable binary, but a dynamic library instead. After some digging I found that this is supported, but the support is somehow crippled.

Long story short, just change the Godot binary filename to include “python”. So in my case I renamed Godot_v3.0.2-stable_win64.exe to python_Godot_v3.0.2-stable_win64.exe.

That’s not a joke, that’s one of the workaround for a bug/missing feature. If you want to know more, check these PyCharm tickets:

  • PY-25926 Add ability to attach to Python processes without a “python” word in the executable name
  • PY-14181 Attach to processes where python is embedded, not just python.exe

PyCharm setup

If you haven’t, create a project in the Godot project directory. You might need to set a project structure in settings.

Then select the right interpreter which should be somewhere in directory pythonscript. When I first did that, I actually made a silly mistake by selecting a new virtualenv interpreter. So just for these screenshots and you’re safe.

As you can see above, use “System interpreter”, don’t create a Virtualenv.

Run the project from the Godot editor, set some breakpoints in PyCharm and use “Attach to Local Process”.

The highlighted process was the right for me, for you it will look similar.

--

--