Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange error while using Pycharm to debug PyQt gui

I've been using PyCharm to debug my gui in PyQt. This has been really successful thus far, until I've run into a strange error in trying to debug my gui just now. I've set a breakpoint at the beginning of the script as well as at various points but the program does not have a chance to get to this point. I've also tried removing all the breakpoints and running the debug but get the same result. The full traceback is:

C:\Users\pbreach\Continuum\Anaconda3\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 53720 --file C:/Users/pbreach/Dropbox/FIDS/cci/bluebook/code/input.py
Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevd_cython_wrapper.py", line 2, in <module>
    from _pydevd_bundle.pydevd_cython import trace_dispatch, PyDBAdditionalThreadInfo
ModuleNotFoundError: No module named '_pydevd_bundle.pydevd_cython'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\pydevconsole.py", line 8, in <module>
    from code import InteractiveConsole
ImportError: cannot import name 'InteractiveConsole'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.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.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.3\helpers\pydev\_pydevd_bundle\pydevd_cython_wrapper.py", line 26, in <module>
    mod = __import__(check_name)
  File "_pydevd_bundle\pydevd_cython_win32_36_64.pyx", line 9, in init _pydevd_bundle.pydevd_cython_win32_36_64 (_pydevd_bundle/pydevd_cython_win32_36_64.c:21388)
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.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.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.3\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 75, in <module>
    import pydevconsole
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\pydevconsole.py", line 10, in <module>
    from _pydevd_bundle.pydevconsole_code_for_ironpython import InteractiveConsole
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevconsole_code_for_ironpython.py", line 105
    except SyntaxError, err:
                      ^
SyntaxError: invalid syntax

Process finished with exit code 1

Does anyone know what is causing this error and how it can be resolved? When I run the code normally (without debugging) I do not run into any of these errors.

like image 701
pbreach Avatar asked Mar 09 '17 20:03

pbreach


1 Answers

I ran into the same issue, and it took me a while but I found a solution that works for me. I believe what happens, is that the debugger is looking for the module _pydevd_bundle.pydevd_cython in a directory code. However, because you are running the script out of your own code directory, the debugger checks your folder, sees their is no module, and throws the error. That would explain why deleting the __init__.py works, because the debugger won't confuse the two directories anymore.

So, renaming your code directory to something else, should fix the issue and let you keep the init file.

like image 123
Andrew McNally Avatar answered Oct 04 '22 05:10

Andrew McNally