Debugger not working: code is executed normally
I am running PyCharm Community edition on Windows 7, 64 bit.
When I try to debug my code as shown for example here: https://www.youtube.com/watch?v=QJtWxm12Eo0, I get no information about the debugger (such as "Debugger is active!" message). Needless to say, none of the breakpoints in the project work.
However, the error message output is different when I try to debug:
Normal run:
C:\Anaconda2\python.exe Q:/Abteilungsprojekte/eng/SWWData/Matthew/Workspace/raycast/code/core.py
position is s3_clip_images_2d from log file.
### s3_clip_images_2d
clipping ..\demo_data\images\IMG_1000.tif to C:\temp\pcdTest\s3_clip_images_2d\IMG_1000.tif
Traceback (most recent call last):
File "Q:/Abteilungsprojekte/eng/SWWData/Matthew/Workspace/raycast/code/core.py", line 105, in <module>
main()
File "Q:/Abteilungsprojekte/eng/SWWData/Matthew/Workspace/raycast/code/core.py", line 47, in main
r = globals()[step[3:]](settings, structure, debug)
File "Q:\Abteilungsprojekte\eng\SWWData\Matthew\Workspace\raycast\code\s3_clip_images_2d.py", line 57, in clip_images_2d
image_file_out)
File "Q:\Abteilungsprojekte\eng\SWWData\Matthew\Workspace\raycast\code\s3_clip_images_2d.py", line 152, in clip
poly = lyr.GetNextFeature()
AttributeError: 'NoneType' object has no attribute 'GetNextFeature'
Process finished with exit code 1
Debug run:
C:\Anaconda2\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.3\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 53411 --file Q:/Abteilungsprojekte/eng/SWWData/Matthew/Workspace/raycast/code/core.py
position is s3_clip_images_2d from log file.
### s3_clip_images_2d
clipping ..\demo_data\images\IMG_1000.tif to C:\temp\pcdTest\s3_clip_images_2d\IMG_1000.tif
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.3\helpers\pydev\pydevd.py", line 26, in <module>
from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.3\helpers\pydev\_pydevd_bundle\pydevd_additional_thread_info.py", line 17, in <module>
from _pydevd_bundle.pydevd_cython_wrapper import PyDBAdditionalThreadInfo
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.3\helpers\pydev\_pydevd_bundle\pydevd_cython_wrapper.py", line 26, in <module>
mod = __import__(check_name)
File "_pydevd_bundle\pydevd_cython_win32_27_64.pyx", line 9, in init _pydevd_bundle.pydevd_cython_win32_27_64 (_pydevd_bundle/pydevd_cython_win32_27_64.c:17943)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.3\helpers\pydev\_pydevd_bundle\pydevd_frame.py", line 10, in <module>
from _pydevd_bundle.pydevd_breakpoints import get_exception_breakpoint
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.3\helpers\pydev\_pydevd_bundle\pydevd_breakpoints.py", line 15, in <module>
from _pydevd_bundle.pydevd_comm import get_global_debugger
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.3\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 73, in <module>
import pydevconsole
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.3\helpers\pydev\pydevconsole.py", line 8, in <module>
from code import InteractiveConsole
File "Q:\Abteilungsprojekte\eng\SWWData\Matthew\Workspace\raycast\code\__init__.py", line 1, in <module>
from .core import main
File "Q:\Abteilungsprojekte\eng\SWWData\Matthew\Workspace\raycast\code\core.py", line 105, in <module>
main()
File "Q:\Abteilungsprojekte\eng\SWWData\Matthew\Workspace\raycast\code\core.py", line 47, in main
r = globals()[step[3:]](settings, structure, debug)
File "Q:\Abteilungsprojekte\eng\SWWData\Matthew\Workspace\raycast\code\s3_clip_images_2d.py", line 57, in clip_images_2d
image_file_out)
File "Q:\Abteilungsprojekte\eng\SWWData\Matthew\Workspace\raycast\code\s3_clip_images_2d.py", line 152, in clip
poly = lyr.GetNextFeature()
AttributeError: 'NoneType' object has no attribute 'GetNextFeature'
Process finished with exit code 1
--------------------------------------------
I have tried deleting the .idea folder.
Thanks!
Matthew
请先登录再写评论。
Hi Mattew!
Inside debugger we don't run code directly, we call some additional functions, that's why the traceback differs from the original one. Running your program with debugger sometimes can change its behavior.
The exception in your program appears even when you just run it, not because of the debugger. Its traceback differs from the original one, you're right, but we can't do anything with that.
Hi Elizabeth,
Thanks for your message. I don't think I was clear enough in my question: the problem is that the debugger doesn't stop at any of the breakpoints I set, even breakpoints at the beginning of the script.
Are you sure that the lines with breakpoints were executed?
Could you please record a screen cast, which illustrates the bug? Also could you please set environment variable PYCHARM_DEBUG=True and provide console output?
Here is a screenshot of the bug. I think all important elements are visible, but let me know if you want a video and I will figure out how to do it:
The environment variable PYCHARM_DEBUG is already set in the Debug configuration:
So I am not exactly sure what you would like me to do.
Thank you! Now I can see that the problem exists.
After adding the environment variable, please, run your script under debugger, not just simple run. After that some internal information will be added to the console output. Please, provide it here too.
Actually, the first screenshot in my previous post shows a run with the Debug configuration. If I run normally, then I see something like this:
After creating Run Configuration, you can run it both with debugger or without it.
On both screenshots you ran your configurations with simple 'Run' without debugger (you pressed a green triangle). In order to run it with debugger, you should press the bug icon.
Yes, you are right. Here is the new version:
Don't you have any additional console output with 'PYCHARM_DEBUG' environment variable? Are you able to provide a code sample or sample project for reproducing the bug?
The previous screenshot shows all output, with the 'PYCHARM_DEBUG' environment variable.
I have now tried debugging a simple python script in a new pycharm project, and it works like a charm. So I assume the pycharm installation is fine. I have also tried debugging the project on a different computer, and it also doesn't work. I guess the problem must be somewhere in my python code, then.
The project runs on Windows and requires Numpy and GDAL, so it not so easy to set up. You can find the project with demo data here: https://github.com/mmmatthew/raycast
The problem here is that your code top level package shadows the top level code package required by the console.
The code module is a top level standard Python module so you should probably rename your package to avoid clashing with it.
I am facing similar error , I tried all the above steps but still getting the error. Please advise.
C:\Python31\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 54344 --file C:/Users/xx41569/PycharmProjects/Tryagain/child
PYDEVD_FILTER_LIBRARIES False
Started in multiproc mode
('Connecting to ', '127.0.0.1', ':', '54344')
('Connected.',)
debugger: received >>99 -1 54345
<<
Received command: ??? 99 -1 54345
Received port 54345
pydev debugger: process 20144 is connecting
('Connecting to ', '127.0.0.1', ':', '54345')
('Connected.',)
debugger: received >>501 1 0.1 WIN
<<
Received command: CMD_VERSION 501 1 0.1 WIN
sending cmd --> CMD_VERSION 501 1 @@BUILD_NUMBER@@
Connected to pydev debugger (build 162.1967.10)
debugger: received >>111 3 python-line c:/users/xx41569/pycharmprojects/tryagain/child 4 calling THREAD None None
<<
Received command: CMD_SET_BREAK 111 3 python-line c:/users/xx41569/pycharmprojects/tryagain/child 4 calling THREAD None None
Added breakpoint:c:\users\xx41569\pycharmprojects\tryagain\child - line:4 - func_name:b'calling'
debugger: received >>122 5 python-BaseException 0 1 0
<<
Received command: CMD_ADD_EXCEPTION_BREAK 122 5 python-BaseException 0 1 0
Exceptions to hook on terminate: {'BaseException': <_pydevd_bundle.pydevd_breakpoints.ExceptionBreakpoint object at 0x02E3D170>}
debugger: received >>146 7 SHOW_RETURN_VALUES 1
<<
Received command: CMD_SHOW_RETURN_VALUES 146 7 SHOW_RETURN_VALUES 1
Show return values: True
debugger: received >>101 9
<<
Received command: CMD_RUN 101 9
IDE_PROJECT_ROOTS ['C:/Users/xx41569/PycharmProjects/Tryagain']
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pydev\pydevd.py", line 1580, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pydev\pydevd.py", line 964, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 11, in execfile
stream = tokenize.open(file) # @UndefinedVariable
AttributeError: 'module' object has no attribute 'open'
Handling post-mortem stop on exception breakpoint BaseException
We are stopping in post-mortem
sending cmd --> CMD_THREAD_CREATE 103 2 <xml><thread name="MainThread" id="pid_20144_id_39484528" /></xml>
sending cmd --> CMD_THREAD_SUSPEND 105 4 <xml><thread id="pid_20144_id_39484528" stop_reason="122" message="BaseException"><frame id="49498320" name="execfile" file="c:\program files (x86)\jetbrains\pycharm community edition 2016.2.3\helpers\pydev\_pydev_imps\_pydev_execfile.py" line="11"></frame><frame id="49453088" name="run" file="c:\program files (x86)\jetbrains\pycharm community edition 2016.2.3\helpers\pydev\pydevd.py" line="964"></frame><frame id="37439368" name="<module>" file="c:\program files (x86)\jetbrains\pycharm community edition 2016.2.3\helpers\pydev\pydevd.py" line="1580"></frame></thread></xml>
debugger: received >>114 11 pid_20144_id_39484528 49498320 FRAME
<<
Received command: CMD_GET_FRAME 114 11 pid_20144_id_39484528 49498320 FRAME
('processing internal command ', '<_pydevd_bundle.pydevd_comm.InternalGetFrame object at 0x0288D9F0>')
debugger: received >>114 13 pid_20144_id_39484528 49498320 FRAME
<<
Received command: CMD_GET_FRAME 114 13 pid_20144_id_39484528 49498320 FRAME
('processing internal command ', '<_pydevd_bundle.pydevd_comm.InternalGetFrame object at 0x0288D9F0>')
sending cmd --> CMD_GET_FRAME 114 11 <xml><var name="__exception__" type="tuple" qualifier="builtins" value="<class 'tuple'>: (<class 'AttributeError'>, AttributeError("'module' object has no attribute 'open'",), None)" isContainer="True" /> <var name="file" type="str" qualifier="builtins" value="str: C:/Users/xx41569/PycharmProjects/Tryagain/child" /> <var name="glob" type="dict" qualifier="builtins" value="dict: {'__builtins__': <module 'builtins' (built-in)>, '__name__': '__main__', '__file__': 'C:/Users/xx41569/PycharmProjects/Tryagain/child', '__doc__': None, '__package__': None}" isContainer="True" /> <var name="loc" type="dict" qualifier="builtins" value="dict: {'__builtins__': <module 'builtins' (built-in)>, '__name__': '__main__', '__file__': 'C:/Users/xx41569/PycharmProjects/Tryagain/child', '__doc__': None, '__package__': None}" isContainer="True" /> <var name="tokenize" type="module" qualifier="builtins" value="module: <module 'tokenize' from 'C:\Python31\lib\tokenize.py'>" isContainer="True" /> </xml>
sending cmd --> CMD_GET_FRAME 114 13 <xml><var name="__exception__" type="tuple" qualifier="builtins" value="<class 'tuple'>: (<class 'AttributeError'>, AttributeError("'module' object has no attribute 'open'",), None)" isContainer="True" /> <var name="file" type="str" qualifier="builtins" value="str: C:/Users/xx41569/PycharmProjects/Tryagain/child" /> <var name="glob" type="dict" qualifier="builtins" value="dict: {'__builtins__': <module 'builtins' (built-in)>, '__name__': '__main__', '__file__': 'C:/Users/xx41569/PycharmProjects/Tryagain/child', '__doc__': None, '__package__': None}" isContainer="True" /> <var name="loc" type="dict" qualifier="builtins" value="dict: {'__builtins__': <module 'builtins' (built-in)>, '__name__': '__main__', '__file__': 'C:/Users/xx41569/PycharmProjects/Tryagain/child', '__doc__': None, '__package__': None}" isContainer="True" /> <var name="tokenize" type="module" qualifier="builtins" value="module: <module 'tokenize' from 'C:\Python31\lib\tokenize.py'>" isContainer="True" /> </xml>
debugger: received >>111 15 python-line c:/program files (x86)/jetbrains/pycharm community edition 2016.2.3/helpers/pydev/_pydev_imps/_pydev_execfile.py 11 execfile THREAD None None
<<
Received command: CMD_SET_BREAK 111 15 python-line c:/program files (x86)/jetbrains/pycharm community edition 2016.2.3/helpers/pydev/_pydev_imps/_pydev_execfile.py 11 execfile THREAD None None
Added breakpoint:c:\program files (x86)\jetbrains\pycharm community edition 2016.2.3\helpers\pydev\_pydev_imps\_pydev_execfile.py - line:11 - func_name:b'execfile'
debugger: received >>112 17 python-line c:/program files (x86)/jetbrains/pycharm community edition 2016.2.3/helpers/pydev/_pydev_imps/_pydev_execfile.py 11
<<
Received command: CMD_REMOVE_BREAK 112 17 python-line c:/program files (x86)/jetbrains/pycharm community edition 2016.2.3/helpers/pydev/_pydev_imps/_pydev_execfile.py 11
Removed breakpoint:c:\program files (x86)\jetbrains\pycharm community edition 2016.2.3\helpers\pydev\_pydev_imps\_pydev_execfile.py - line:11 - func_name:b'execfile' (id: 11)
This is what I get in Pydev_exec.py file
Hi,
I solved the issue by deleting the __init__.py file that I had in my project.
Hope it helps...
Arun S2k8 Your problem is different. What python interpreter do you use?
@Matthew,
I don't have __init__.py in my program as of now. This is very basic
@Elizabeth
I am using Python 3.5 and Pycharm community edition editor
Hi All,
I also had same issue in debugging mode but ok in run mode.
The errors below same as above
//////////////////////////////
/usr/bin/python "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 55697 --file /Users/test.py --
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 26, in <module>
from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_additional_thread_info.py", line 19, in <module>
from _pydevd_bundle.pydevd_additional_thread_info_regular import PyDBAdditionalThreadInfo # @UnusedImport
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_additional_thread_info_regular.py", line 5, in <module>
from _pydevd_bundle.pydevd_frame import PyDBFrame
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_frame.py", line 10, in <module>
from _pydevd_bundle.pydevd_breakpoints import get_exception_breakpoint
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_breakpoints.py", line 15, in <module>
from _pydevd_bundle.pydevd_comm import get_global_debugger
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 75, in <module>
import pydevconsole
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevconsole.py", line 12, in <module>
from code import compile_command
ImportError: cannot import name compile_command
Process finished with exit code 1
/////////////////////////
even I deleted __init__.py and set correctly PYCHARM_DEBUG = true.
I used
IDE -> PyCharm Community Edition 2016.3.1
#PC-163.9735.8, built on Dec 15, 2016
Python Interpreter -> Python 2.7.10
Really appreciate your kind advice..
Best regards
I'm not sure if this has been solved but I've learned that you have to be careful as to what you call your functions. It looks like you were trying to call a script called core.py. I ran into this issue when I had a file called io. I was able to debug a function called "core' on my setup but perhaps there is a difference in our PyCharm version. Try changing the name of the script that your trying to call.
Same problem here. Without solution yet.
Hello,
Please vote for the existing ticket in order to increase its priority https://youtrack.jetbrains.com/issue/PY-23615
Dear All,
Could anyone help me fixing this issue? I am able to run the application without any issue. However debug is not working?