Debugging in Linux when Calling Popen
I just installed PyCharm 2.6.3 on RedHat Enterprise Linux 6.2 and have imported pre-existing python code into the IDE. The code runs fine and I can debug it except when I try to spawn a new thread. I am unable to stop on a breakpoint in the new thread.
Do I need to add the PyChar-2.6.3/helper/pydev to my PythonPath to get it to work?
Changed to more accurately reflect issue.
Do I need to add the PyChar-2.6.3/helper/pydev to my PythonPath to get it to work?
Changed to more accurately reflect issue.
Please sign in to leave a comment.
It is possible to debug new threads in PyCharm.
Could you please provide the script you trying to debug and we'll what goes wrong here.
Thank you for gelping.
There are several hundred files involved in a large package so it will be close to impossible for to ship a useful file for you to debug. Since the feature is supported, it must be a configuration issue on my side or a odd niche system configuration that PyCharm is not expecting.
When using eclipse I used the open source version of pydev and did a import pydevvd pydevd.settrace(). Looking at the pycharm version of pydevd there is a settrace() method but it does not look like I need to call it manually for pycharm.
Looking through the forums there was a suggestion to set: PYCHARM_DEBUG=true. I set that and also enabled the "Background Tasks" window. It comes back with the message "Connecting to debugger" and keeps on scanning.
See the attached file for the debug screen.
output.txt (17KB)
There was a suggestion set set –noreload but I am either passing it to the python debugger or to my python script and the –noreload option is not be accepted.
Any debugging suggestions to get you more data would be appreciated.
Regards,
Tam
import threading
def on_start_button_clicked(self, widget):
widget.set_sensitive(False)
self.pause_button.set_sensitive(True)
self.stop_button.set_sensitive(True)
self.test_thread = threading.Thread(target = self.test_manager.execute_list, name = 'execution_thread', args = (self.console,))
self.test_thread.start()
From eclipse with pydevd plugin we can insert breakpoints into python files called from Popen by inserting:
import pydevd
pydevd.settrace()
This implementation is not supported in PyCharm. PyCharm does support remote debugging but it is not obvious how to to enable that for the same system.
See attached project file to reproduce issue.
processTest.tar (40KB)
import pydevdd
pydevd.settrace('localhost', port=55000)
Note the port is set in
Reference discussion below.
http://blog.jetbrains.com/pycharm/2010/12/python-remote-debug-with-pycharm/
The attached file has a sample project that gives and example.
processTest.tgz (839KB)
Debugging of multiple processes is also supported in PyCharm (sorry I didn't mention Popen in question head and thought that you are asking about threads).
If Settings | Debugger | Python | Attach to subprocesses automaticaly checkbox is enabled PyCharm attachs it's debugger to every spowned process.
Remote debugging can also help in that case, but it requires some cumbersome manipulations.
Checking "Attached to subprocess automatically" was one of the first things I tried but still could not step into the code for debugging.
Just tried what you suggested with the sample processTest project above and still could not successfully step into code.
I am wondering if the issue I am seeing with some incompatibility with version of Java or python.
Here is my java version
/pycharm.sh
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01, mixed mode)
Warning: The encoding 'UTF-8' is not supported by the Java runtime.
[ 82724] WARN - .packaging.PyPIPackagesUpdater - Connection timed out
Here is my python version
Python 2.6.6 (r266:84292, Aug 28 2012, 10:55:56)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Regards,
Tam
Regards,
Tam
Could you please set PYCHARM_DEBUG environment variable in your run configuration and provide console output after you run your script.
As you specified I enabled the PYCHARM_DEBUG environment variable.
I used the same project that I uploaded above processTest.tgz and disabled the line pydevd.settrace in externalPythonFile.
See attached for debug output from the console window.
Please feel free to contanct me if you need any more characterization to help with a workaround or fix.
outputtest.txt (8.1KB)