Django:tkinter / matplotlib - TclError - 空主窗口

时间:2016-03-19 15:19:41

标签: python django python-3.x matplotlib

我的Django项目出错了。由于主线程在主循环之外执行,似乎tkinter抛出错误。这种情况在Django或Matplotlib中隐含发生,任何人都可以就导致此问题的原因提出建议。

这是Django中的错误......

Internal Server Error: /stocks/
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py", line 149, in get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py", line 147, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.4/dist-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/philip/PycharmProjects/stockmarket/cs_coursework/views.py", line 161, in post
    self.graphData(request.POST["ticker"])
  File "/home/philip/PycharmProjects/stockmarket/cs_coursework/views.py", line 130, in graphData
    fig = plt.figure()
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 423, in figure
    **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 79, in new_figure_manager
    return new_figure_manager_given_figure(num, figure)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 96, in new_figure_manager_given_figure
    icon_img = Tk.PhotoImage(file=icon_fname)
  File "/usr/lib/python3.4/tkinter/__init__.py", line 3419, in __init__
    Image.__init__(self, 'photo', name, cnf, master, **kw)
  File "/usr/lib/python3.4/tkinter/__init__.py", line 3375, in __init__
    self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: NULL main window
[19/Mar/2016 14:58:44] "POST /stocks/ HTTP/1.1" 500 128763
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/matplotlib/_pylab_helpers.py", line 86, in destroy_all
    manager.destroy()
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 584, in destroy
    self.window.destroy()
  File "/usr/lib/python3.4/tkinter/__init__.py", line 1895, in destroy
    for c in list(self.children.values()): c.destroy()
  File "/usr/lib/python3.4/tkinter/__init__.py", line 2131, in destroy
    self.tk.call('destroy', self._w)
RuntimeError: main thread is not in main loop

Process finished with exit code 139

如果您需要我的任何代码,请留言我不确定我应该发布什么代码条款。

除了退出代码139,有时我会得到退出代码134。

非常感谢帮助。

感谢。

0 个答案:

没有答案