2011-07-25 60 views
5

我跟着官方文件,安裝的virtualenv和瓶,然後python hello.py 但也有一些是錯誤的:瓶的 「Hello World」 不能在調試模式運行

* 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 

回答

5

這似乎是pyinotify中的API的變化,你還必須安裝由此引發的錯誤。您可以刪除pyinotify或使用骯髒的黑客強制它使用stat()而不是pyinotify。要行496 werkzeug/serving.py嘗試加入(以下地方嘗試導入pyinotify中的部分):

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

確保到bug也報告給werkzeug開發商。

+3

是的,它會被固定在werkzeug 0.7.1。而IPython還有另外一個類似的問題。 – plaes

+0

這很有幫助,謝謝! – dormouse