烧瓶“你好世界”无法在调试模式下运行

发布于 2024-11-26 07:33:53 字数 1835 浏览 2 评论 0 原文

我按照官方文档,安装了virtualenv和flask,然后安装了python hello.py 但是有问题:

 * Running on http://127.0.0.1:5000/
 * Restarting with reloader: inotify events
Traceback (most recent call last):
  File "hello.py", line 9, in <module>
    app.run(debug=True)
  File "/home/aa/prj/env/lib/python2.7/site-packages/Flask-0.7.2-py2.7.egg/flask/app.py", line 553, in run
    return run_simple(host, port, self, **options)
  File "/home/aa/prj/env/lib/python2.7/site-packages/Werkzeug-0.7-py2.7.egg/werkzeug/serving.py", line 609, in run_simple
    run_with_reloader(inner, extra_files, reloader_interval)
  File "/home/aa/prj/env/lib/python2.7/site-packages/Werkzeug-0.7-py2.7.egg/werkzeug/serving.py", line 528, in run_with_reloader
    reloader_loop(extra_files, interval)
  File "/home/aa/prj/env/lib/python2.7/site-packages/Werkzeug-0.7-py2.7.egg/werkzeug/serving.py", line 436, in reloader_loop
    reloader(fnames, interval=interval)
  File "/home/aa/prj/env/lib/python2.7/site-packages/Werkzeug-0.7-py2.7.egg/werkzeug/serving.py", line 464, in _reloader_inotify
    mask = reduce(lambda m, a: m | getattr(EventsCodes, a), mask, 0)
  File "/home/aa/prj/env/lib/python2.7/site-packages/Werkzeug-0.7-py2.7.egg/werkzeug/serving.py", line 464, in <lambda>
    mask = reduce(lambda m, a: m | getattr(EventsCodes, a), mask, 0)
AttributeError: type object 'EventsCodes' has no attribute 'IN_DELETE_SELF'

我的hello.py:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return "Hello World!"

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

但是如果没有调试就可以了吗?为什么? 我的/env/lib/python2.7/site-packages:

distribute-0.6.10-py2.7.egg
Jinja2-2.6-py2.7.egg
Werkzeug-0.7-py2.7.egg
easy-install.pth
pip-0.7.2-py2.7.egg

I followed official document, installed virtualenv and flask, and then python hello.py
But there is something wrong:

 * Running on http://127.0.0.1:5000/
 * Restarting with reloader: inotify events
Traceback (most recent call last):
  File "hello.py", line 9, in <module>
    app.run(debug=True)
  File "/home/aa/prj/env/lib/python2.7/site-packages/Flask-0.7.2-py2.7.egg/flask/app.py", line 553, in run
    return run_simple(host, port, self, **options)
  File "/home/aa/prj/env/lib/python2.7/site-packages/Werkzeug-0.7-py2.7.egg/werkzeug/serving.py", line 609, in run_simple
    run_with_reloader(inner, extra_files, reloader_interval)
  File "/home/aa/prj/env/lib/python2.7/site-packages/Werkzeug-0.7-py2.7.egg/werkzeug/serving.py", line 528, in run_with_reloader
    reloader_loop(extra_files, interval)
  File "/home/aa/prj/env/lib/python2.7/site-packages/Werkzeug-0.7-py2.7.egg/werkzeug/serving.py", line 436, in reloader_loop
    reloader(fnames, interval=interval)
  File "/home/aa/prj/env/lib/python2.7/site-packages/Werkzeug-0.7-py2.7.egg/werkzeug/serving.py", line 464, in _reloader_inotify
    mask = reduce(lambda m, a: m | getattr(EventsCodes, a), mask, 0)
  File "/home/aa/prj/env/lib/python2.7/site-packages/Werkzeug-0.7-py2.7.egg/werkzeug/serving.py", line 464, in <lambda>
    mask = reduce(lambda m, a: m | getattr(EventsCodes, a), mask, 0)
AttributeError: type object 'EventsCodes' has no attribute 'IN_DELETE_SELF'

my hello.py:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return "Hello World!"

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

but if without debug that's ok? why?
my /env/lib/python2.7/site-packages:

distribute-0.6.10-py2.7.egg
Jinja2-2.6-py2.7.egg
Werkzeug-0.7-py2.7.egg
easy-install.pth
pip-0.7.2-py2.7.egg

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尐籹人 2024-12-03 07:33:53

这似乎是由 pyinotify 的 API 更改引发的错误,您也必须安装该 API。您可以删除 pyinotify 或使用肮脏的 hack 强制它使用 stat() 而不是 pyinotify。在 werkzeug/serving.py 的第 496 行尝试添加(在尝试导入 pyinotify 的部分下方):

# dirty hack
reloader = _reloader_stat_loop
reloader_name = "stat() polling"

确保同时向 werkzeug 开发人员。

This seems to be a bug triggered by a change in pyinotify's API, which you must also have installed. You could remove pyinotify or use a dirty hack to force it to use stat() instead of pyinotify. To line 496 of werkzeug/serving.py try adding (below the part where it attempts to import pyinotify):

# dirty hack
reloader = _reloader_stat_loop
reloader_name = "stat() polling"

Make sure to also report the bug to the werkzeug developers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文