python - 为什么烧瓶自动调试在 ubuntu 中不起作用
问题描述
当我跑
python app.py
其中的内容app.py
是:
from flask import Flask ,render_template
from data import articles
app=Flask(__name__)
Articles=articles()
@app.route('/')
def index():
return render_template('home.html')
@app.route('/about')
def about():
return render_template('about.html')
@app.route('/articles')
def articles():
return render_template('articles.html',articles=Articles)
@app.route('/article/<string:id>/')
def article(id):
return render_template('article.html',id=id)
if __name__=='__main__':
app.run(debug=True)
我收到以下错误:
Traceback (most recent call last):
File "app.py", line 32, in <module>
app.run(debug=True)
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1344, in > _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error:
/home/haseeb/Documents/Flask/flask_web/app.py
解决方案
要在 Ubuntu 中启用 Flask 调试,您可以执行以下操作: 为 Flask 设置环境变量:
$ export FLASK_DEBUG=1
$ export app=app.py # change to whatever the filename is
然后通过键入以下命令运行您的 Flask 应用程序:
$ run flask
从文档
推荐阅读
- python - Pandas Python 每 3 行最高 2 行并列出结果
- android - 在 android 11 (API 30) 中获取所有已安装的应用程序,如何在 android 11 中安装所有其他应用程序?
- java - 循环不起作用,程序只是继续运行
- snakemake - “输入文件由另一个作业更新”但不是真的
- javascript - apollo 的 useQuery 数据在 client.resetStore() 之后没有更新
- pytest - Pytest 找不到文件/模块
- docker - 如何在 VsCode 的 docker 中调试我的 Startup.cs(调试器附加得太晚)
- c++ - 如何重定向标头路径?
- javascript - 修改 Strapi 中的默认查找服务
- javascript - 如何使用 reducer 函数更改属性的值