teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

捕捉追加(スタックトレース??)

2017/06/22 12:56

投稿

violineer
violineer

スコア72

title CHANGED
File without changes
body CHANGED
@@ -30,4 +30,56 @@
30
30
  の分でなぜか
31
31
  NameError: name 'cv2' is not defined
32
32
  となってしまいます。他のcv2コマンドは受け付けています。どうなっているのでしょうか……??
33
- 何度も再起動等試しました。
33
+ 何度も再起動等試しました。
34
+
35
+ 捕捉:spyderを使用しています。
36
+ スタックトレースを見る方法がわからなかったのですが、これであっていますかね??
37
+ import pdb; pdb.set_trace()
38
+ をコードに書き加え、実行したら以下の通りにコンソールに表示されました。
39
+
40
+
41
+ ```python
42
+ import pdb; pdb.set_trace()
43
+ --Call--
44
+ > c:\winpython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\ipython\core\displayhook.py(236)__call__()
45
+ 235
46
+ --> 236 def __call__(self, result=None):
47
+ 237 """Printing with history cache management.
48
+
49
+
50
+ ipdb> --Call--
51
+ > c:\winpython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\ipython\core\displayhook.py(236)__call__()
52
+ 235
53
+ --> 236 def __call__(self, result=None):
54
+ 237 """Printing with history cache management.
55
+
56
+
57
+ ipdb>
58
+ ```
59
+
60
+ 236周辺はこちらです
61
+ ```python
62
+ def finish_displayhook(self):
63
+ """Finish up all displayhook activities."""
64
+ io.stdout.write(self.shell.separate_out2)
65
+ io.stdout.flush()
66
+ 236
67
+ def __call__(self, result=None):
68
+ """Printing with history cache management.
69
+
70
+ This is invoked everytime the interpreter needs to print, and is
71
+ activated by setting the variable sys.displayhook to it.
72
+ """
73
+ self.check_for_underscore()
74
+ if result is not None and not self.quiet():
75
+ self.start_displayhook()
76
+ self.write_output_prompt()
77
+ format_dict, md_dict = self.compute_format_data(result)
78
+ self.update_user_ns(result)
79
+ self.fill_exec_result(result)
80
+ if format_dict:
81
+ self.write_format_data(format_dict, md_dict)
82
+ self.log_output(format_dict)
83
+ self.finish_displayhook()
84
+ コード
85
+ ```