gpt4 book ai didi

python - 断言失败 : Flask server stops after script is run

转载 作者:行者123 更新时间:2023-11-28 20:57:10 24 4
gpt4 key购买 nike

我有一个 Flask 应用程序,当用户单击索引页面上的按钮时,他们会触发生成报告,并使用 send_file() 函数将报告下载到他们的浏览器。

每次创建和下载报告时,服务器都会停止,我会在终端中收到以下错误。每次都需要重新启动,我不知道如何修复它。有任何想法吗? :)

flask_app.py 文件:

from flask import Flask, render_template, request, url_for, flash
import create_report
from flask_debugtoolbar import DebugToolbarExtension
from flask import send_file

app = Flask(__name__)
filename = ""

@app.route("/")
def index():
return render_template("index.html")

@app.route("/handle_data", methods=['GET', 'POST'])
def handle_data():
text = request.form['accountinput']
preprocessed_text = text.lower()
filename = create_report.start_script(preprocessed_text)
path = "reports/" + filename
return send_file(path, as_attachment=True)

if __name__ == '__main__':
app.run(debug=True)

终端错误:

Assertion failed: (NSViewIsCurrentlyBuildingLayerTreeForDisplay() != currentlyBuildingLayerTree), function NSViewSetCurrentlyBuildingLayerTreeForDisplay, file /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.60.100/AppKit.subproj/NSView.m, line 14485.

最佳答案

你应该开始你的程序

import matplotlib
matplotlib.use('Agg')

由于create_report 模块使用matplotlib,对于matplotlib this is a common case .

关于python - 断言失败 : Flask server stops after script is run,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53684971/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com