2015-06-23 64 views
4

當我導入Theano時,我無法讓PyCharm在引發異常的代碼行停止。PyCharm中斷異常無法與Theano配合使用

我的代碼:

import theano 
raise Exception() 

我希望PyCharm調試器停在raise Exception()線,但它拋出一個RuntimeError和退出調試程序:

Traceback (most recent call last): 
Error in sys.excepthook: 
Traceback (most recent call last): 
    File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd_breakpoints.py", line 89, in _excepthook 
    _original_excepthook(exctype, value, tb) 
    File "/usr/local/lib/python2.7/dist-packages/theano/gof/link.py", line 58, in thunk_hook 
    __excepthook(type, value, trace) 
    File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd_breakpoints.py", line 89, in _excepthook 
    _original_excepthook(exctype, value, tb) 
    File "/usr/local/lib/python2.7/dist-packages/theano/gof/link.py", line 58, in thunk_hook 
    __excepthook(type, value, trace) 
    <...> 
    File "/usr/local/lib/python2.7/dist-packages/theano/gof/link.py", line 58, in thunk_hook 
    __excepthook(type, value, trace) 
    File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd_breakpoints.py", line 84, in _excepthook 
    exception_breakpoint = get_exception_breakpoint(exctype, _handle_exceptions) 
    File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd_breakpoints.py", line 65, in get_exception_breakpoint 
    exception_full_qname = get_exception_full_qname(exctype) 
    File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd_breakpoints.py", line 53, in get_exception_full_qname 
    def get_exception_full_qname(exctype): 
RuntimeError: maximum recursion depth exceeded 

Original exception was: 
Traceback (most recent call last): 
    File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd.py", line 2357, in <module> 
    globals = debugger.run(setup['file'], None, None, is_module) 
    File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd.py", line 1777, in run 
    pydev_imports.execfile(file, globals, locals) # execute the script 
    File "/homes/user/corp/python/projects/n_test.py", line 10, in <module> 
    raise Exception() 
Exception 
+0

通常,當python全局解釋器遞歸編譯theano代碼超過允許值時,會發生'RuntimeError:超過最大遞歸深度'。爲什麼它會在導入時發生,我不知道,但是您可以將最大深度設置爲更大(1e6)的數字,然後查看是否有幫助。 – user2805751

+0

嘗試更新點子。在執行'sudo -H pip install --upgrade pip'之前,我有同樣的錯誤。我使用'sudo -H',因爲它在OSX 10.11.2上。 – Znatz

回答

0

一個黑客是註釋掉這行sys.excepthook = thunk_hook.../lib/python2.7/site-packages/theano/gof/link.py

+0

除非是缺陷或缺失功能,否則修補庫代碼不是真正的解決方案。 –

+0

儘管這聽起來像一個錯誤。 –

0

看起來像一個庫中的錯誤(也許都是:^))。

由於某種原因,theanoPyCharm的優秀表現都認爲另一個作爲其祖先。

添加調試打印成兩庫在哪裏sys.excepthook和成員變量指向先前的處理程序被設置爲顯示設置順序點。有人似乎打破了處理程序鏈接規則。