Debugging with Pycharm?

1,074 views
Skip to first unread message

BigJMoney

unread,
Jun 5, 2017, 8:53:48 PM6/5/17
to Evennia
Curious if anyone's got this working in Windows.  I set up my interpreter using this info https://github.com/evennia/evennia/wiki/Setting-up-PyCharm

I'm able to attach to evennia_runner.  I even was successful figuring out how to create a working Run Configuration for evennia so I can launch from inside the IDE (yay!).  But when I run in debug mode it's not actually following evennia's code; i.e. my break points do nothing and I can't watch variables.  It's like it's not really in debug mode.  I tried adding the environment variable PYTHON_DEBUG=true just in case, and played with some checkboxes in the Run Config but no avail yet.

BigJMoney

unread,
Jun 5, 2017, 9:03:45 PM6/5/17
to Evennia
Update: actually it partially works.  Breakpoints I set in evennia/server/evennia_launcher.py work.  It's the breakpoints in my game that aren't working.

The way my project is set up is that I started by loading my game folder.  Then I added evennia and pyenv in there as well.

BigJMoney

unread,
Jun 6, 2017, 9:43:56 AM6/6/17
to Evennia
The more I mess with this the more I think this could be a PyCharm Community Edition limitation.  I notice that PyCharm is supposed to have a Threads pane in the debugger and I can't find it, not does Ctr+Shift+A return anything when I enter 'thread'.

I don't see this specifically listed as exclusive to Pro edition but I do see that the Thread Concurrency Visualization is exclusive, so stepping into the server thread from the runner might not work... I will try a couple other things but if anyone has experience with this fee free to chime in.

BigJMoney

unread,
Jun 6, 2017, 10:17:25 AM6/6/17
to Evennia
Actually Community Edition does have a Threads pane except it's not called that; it's called the Frames pane (which is contrary to the Pycharm documentation on this feature...which I might add is almost as bad as git documentation.)

Anyway I'm still messing with this.  It seems related to evennia threads somehow but haven't figured it out yet.  When I try to switch into other threads while I have evennia_runner suspended there's a PyCharm notice: 'Frames not available in non-suspended state'.

BigJMoney

unread,
Jun 6, 2017, 12:49:38 PM6/6/17
to Evennia
I finally figured this out.  The wiki had you attaching to Evennia's runner process which isn't the server.  To someone new like me this led down a rabbit-hole, so I've updated the wiki.  On the plus side, I forced myself to learn how to set up a PyCharm run configuration for Evennia and learn a but about how the virtualenv scripts invoke the application on Windows.

Griatch Art

unread,
Jun 6, 2017, 1:01:30 PM6/6/17
to Evennia
Glad you figured it out and thanks for updating the wiki! I don't run PyCharm myself but I know many do. :)
.
Griatch

Drakmir

unread,
Dec 5, 2017, 6:46:12 PM12/5/17
to Evennia
While I was able to follow this guide, it does seem to be a bit cumbersome to work with Evennia in PyCharm.

Notable issues are the lack of code completion and inability for the debugger to work with the subprocesses.  Typically, PyCharm will attach to subprocesses spawned using pOpen, but I'm not sure why it fails to do this with Evennia.

I've posted my question on PyCharm's site, but I also figured I'd cross link it here in case others have more insights into what we could do to make this work better:


If PyCharm isn't the IDE of choice for Evennia, what do others use?  Do they have similar issues?

Thanks for any insights!

Julia Willson

unread,
Dec 6, 2017, 8:08:31 AM12/6/17
to Evennia
Code completion isn't Pycharm's fault.  You're not going to get that for imports.  I do get code completion when I do fully qualified import paths.  But the lack of completion is usually due to one of two things (the way the project is structured, the way your Pycharm project is configured).  Can you give an example of something that doesn't have code completion?

I agree though about the subprocesses.  After following instructions on the wiki page linked here for a run/debug configuration (not attach to local process), I am hitting breakpoints in things like default_cmds.py setup (which is not in the evennia_launcher.py but on the server).  When I add the PYCHARM_DEBUG=True environment variable to my configuration, it does show up as being connected to the correct processes and I'm using Community Edition.  I think there might be something wrong with your project configurations because it seems like I got further?  I still cannot hit breakpoints inside commands that are run though after the server is started. 

Julia Willson

unread,
Dec 6, 2017, 8:08:31 AM12/6/17
to Evennia
There is a setting you will need to turn on to attack to subprocesses.
You can find it in File > Settings > (search for debugger) > Python Debugger (it's at the bottom for me in the left pane) > "Attach to subprocess automatically while debugging"

You will also need to make sure that the "Emulate terminal output console" option in your run/debug configuration is checked or it's going to have a bad time.

Not sure if you'd found these yet, so just wanted to pass along how far I've gotten.


On Tuesday, December 5, 2017 at 3:46:12 PM UTC-8, Alan Wood wrote:
Reply all
Reply to author
Forward
0 new messages