Reputation: 11
I'm using python as a scripting language for game logic in the coco2d-x game engine. I know how to debug python scripts in Pycharm.
How can I debug my python scripts when they are called by another program? In my case, it's a simulator provided by the game engine. If scripts are not started inside Pycharm, can Pycharm still somehow capture the scripts' excecuting process?
I tried to use "attach to a local process", but can't find any. I've read related topics like "how to step through python code","remote debug". But can't find similar topics that address my problem.
Upvotes: 0
Views: 507
Reputation: 11
I found a solution for this myself. I used the Remote Debug mentioned in the question.
In the python project you have to write the following code for this to work.
sys.path.append("<path to python>")
sys.path.append("<path to python>/Lib")
sys.path.append("<path to python>/DLLs")
sys.path.append("<path to pycharm-debug.egg>">
import pydevd
pydevd.settrace(host="localhost", port=<your port>, suspend=False, stdoutToServer=True, stderrToServer=True)
This only works if the caller program supports something like the "-debug" arg in my case.
My question is kind of a duplicate of this one. debugging a uwsgi python application using pycharm
Upvotes: 1