我在mac上使用app.run(debug=True)
运行以下代码。我可以在debug=False
时运行代码并测试应用程序,但是当我尝试使用debug=True
时,我收到以下错误:
Traceback (most recent call last):
File "/anaconda3/lib/python3.6/site-packages/IPython/utils/py3compat.py", line 186, in execfile
exec(compiler(f.read(), fname, 'exec'), glob, loc)
File "/flaskhello.py", line 42, in <module>
app.run(host='0.0.0.0', port = 5004, debug = True)
File "/anaconda3/lib/python3.6/site-packages/flask/app.py", line 841, in run
run_simple(host, port, self, **options)
File "/Users/DGS-Mkt/anaconda3/lib/python3.6/site-packages/werkzeug/serving.py", line 737, in run_simple
reloader_type)
File "/Users/DGS-Mkt/anaconda3/lib/python3.6/site-packages/werkzeug/_reloader.py", line 265, in run_with_reloader
sys.exit(reloader.restart_with_reloader())
SystemExit: 1
以下是代码:
from flask import Flask, render_template
app = Flask(__name__)
questions = ['Is it compiled?', 'Does it run on a VM?']
guesses = ['Python', 'Java', 'C++']
@app.route('/')
def index():
return render_template('index.html')
@app.route('/question/<int:id>')
def question(id):
return render_template('question.html', question=questions[id])
@app.route('/guess/<int:id>')
def guess(id):
return render_template('guess.html', guess=guesses[id])
if __name__ == '__main__':
app.run(debug=True)
答案 0 :(得分:0)
我认为问题不是在mac上运行烧瓶。也许你在anaconda有一些问题。我向你建议的2个解决方案:
hibernate.hbm2ddl.auto
或者您可以从anaconda卸载软件包
app = Flask(__name__)
app.config['DEBUG'] = True
并使用pip
进行安装conda remove flask
conda remove werkzeug