在Windows上的烧瓶重装模块

时间:2017-01-08 12:24:56

标签: python flask

我在Windows上,使用python 2.7,使用pip安装。我想在源代码更改后让烧瓶重新加载我的python模块。我做了

SET FLASK_APP=backend.py
set FLASK_DEBUG=1
flask run

这会导致以下错误:

* Serving Flask app "backend"
 * Forcing debug mode on
 * Restarting with stat
c:\python27\python.exe: can't open file 'C:\Python27\Scripts\flask': [Errno 2] No such file or directory

所以我尝试过(正如其他人所建议的那样)

python -m flask run

然而导致以下错误:

 * Serving Flask app "backend"
 * Forcing debug mode on
 * Restarting with stat
 * Debugger is active!
 * Debugger pin code: 168-045-575
 * Debugger is active!
 * Debugger pin code: 243-777-971
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [08/Jan/2017 15:22:29] "GET / HTTP/1.1" 500 -
Traceback (most recent call last):
  File "D:\Projects\MyWebApp\backend.py", line 21, in <module>
    app.run()
  File "C:\Python27\lib\site-packages\flask\app.py", line 843, in run
    run_simple(host, port, self, **options)
  File "C:\Python27\lib\site-packages\werkzeug\serving.py", line 692, in run_simple
    reloader_type)
  File "C:\Python27\lib\site-packages\werkzeug\_reloader.py", line 242, in run_with_reloader
    signal.signal(signal.SIGTERM, lambda *args: sys.exit(0))
ValueError: signal only works in main thread

如何让Windows在Windows上使用自动重新加载器运行?

1 个答案:

答案 0 :(得分:1)

修正了如snakecharmerb所述的werkzeug 0.11.13。之后

pip install werkzeug --upgrade

重装正在按预期工作。