Enabling PyCharm with an app that embeds python?

I have an app that embeds python 2.7 as it's scripting language, is there anything I can do to enable PyCharm to be able to debug python scripts running inside my app?

The python (2.7) shared library is linked into my app and is run by calling the standard C Python entry points, so it calls Py_CompileString() and Py_EvalCode() etc. The python library is distributed with my app, but it has all the components of a standard python 2.7 install. 

Thanks,

James

6 comments
Comment actions Permalink
Official comment

Hi James! You can use Attach to Local Process tool https://www.jetbrains.com/help/pycharm/2016.2/attaching-to-local-process.html
Does it help?

Comment actions Permalink

Hi Elizabeth,

 Unfortunately no, it doesn't. The problem with Attach to Local Process tool is that it appears to look around for processes that are called "python". Since my app isn't called python it doesn't show up there at all. But I did notice that when I do attach to some python process I see this in the PyCharm window:

C:\Python27\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.2\helpers\pydev\pydevd_attach_to_process\attach_pydevd.py" --port 59232 --pid 11804

Which led me to the README in there that says:

"Note that the client is responsible for having a remote debugger alive in the given port for the attach to work.".

I'm hoping that is referring to the standard python debugger module, do you know if it is? I can run the remote debugger inside my app with that port so then maybe the remaining problem will be getting PyCharm to list my app, not just the ones called python. Maybe? Perhaps I can just run the attach_pydevd from the python console in PyCharm and pass in the pid of my app?

Thanks for your reply,

James

1
Comment actions Permalink

Oh and docs say this only works on Windows and Linux, sad-mac-face, why no mac?

 

0
Comment actions Permalink

Can someone please clarify how PyCharm identifies processes to show for the Attach to Local Process feature?  I have a similar situation where we have an embedded python interpreter in a C++ code and PyCharm does not find it, but we would be happy to adjust our code so it can be found. PyCharm lists python.exe, pythonw.exe, and pythonservice.exe processes, but not our application.

We would prefer to use Attach to Local Process for its simplicity vs Remote Debugging.

0
Comment actions Permalink

mengrut At the moment PyCharm shows all the processes with the word "python" in a executable's name. We're going to change this behaviour: https://youtrack.jetbrains.com/issue/PY-25926

0
Comment actions Permalink

Elizabeth:  Looking forward to using it!  Thanks for letting us know.

0

Please sign in to leave a comment.