20tab / UnrealEnginePython

Embed Python in Unreal Engine 4
MIT License
2.77k stars 753 forks source link

pycharm remote debug #527

Open positiveczp opened 6 years ago

positiveczp commented 6 years ago

how to use pycharm remote debug in python console, my code is

def test(): import os import sys sys.path.append(os.path.join(os.path.dirname(file), 'pycharm-debug')) sys.path.append(os.path.join(os.path.dirname(file), 'pycharm-debug.egg')) print 'pycharm_debug init' import pydevd pydevd.settrace('127.0.0.1', port=5555, stdoutToServer=True, stderrToServer=True, suspend=False) print 'pycharm_debug ok'

test()

when running this code, the ue4 will block

rdeioris commented 6 years ago

Hi, the main Python VM runs in the main UE thread, so you cannot interrupt it without interrupting the UE loop. I think you could try adding the breakpoint in a new python thread (never tried it)

positiveczp commented 6 years ago

why never try it ? how can i debug use pycharm?

rdeioris commented 6 years ago

"i" never tried it :) Well just try my suggestion, i do not use pycharm, any feedback will be useful

positiveczp commented 6 years ago

that is say : we can not use remote debug with pycharm

rdeioris commented 6 years ago

Sorry i do not understand what you mean. I gave you a possible solution, have you tried it ?

positiveczp commented 6 years ago

a possible solution ? try adding the breakpoint in a new python thread?

rdeioris commented 6 years ago

yep, it is a common pattern, if you want ue to continue running you cannot block it. Using a different python thread will allow you to spawn the debug server and eventually attach to the right thread from the debugger client. This works in plain pdb, no idea for pycharm

positiveczp commented 6 years ago

ok, thank you very much

pilgrim333 commented 4 years ago

Did you get pycharm remote debug to work with UE4? If you did, can you share? Thank you.