0

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.

1 Answer 1

1

I found a solution for this myself. I used the Remote Debug mentioned in the question.

  1. Set the "Local host name" to "localhost" and set the port.
  2. Then extract the "pycharm-debug-py3k.egg" file to some directory.
  3. Start the Game.exe with args "-debug %EGG_PATH% %PYTHON_PATH% %PORT%".

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.