flask: "[Errno 2] No such file or directory" on flask run with FLASK_DEBUG=1

I get the following [Errno 2] No such file or directory with flask 0.11 & werkzeug 0.11.10 on Windows 7 64bit with Python 3.5 but only when FLASK_DEBUG=1.

D:\tmp
λ python --version
Python 3.5.1 :: Continuum Analytics, Inc.

D:\tmp
λ python -c "import hello_flask"

D:\tmp
λ set FLASK_APP=hello_flask.py

D:\tmp
λ flask run
 * Serving Flask app "hello_flask"
 * Forcing debug mode off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

D:\tmp
λ set FLASK_DEBUG=1

D:\tmp
λ flask run
 * Serving Flask app "hello_flask"
 * Forcing debug mode on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with windowsapi reloader
d:\anaconda3\envs\flask\python.exe: can't open file 'D:\Anaconda3\envs\flask\Scripts\flask': [Errno 2] No such file or directory

hello_flask.py is the minimal app from the docs.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 30 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I faced the same error. However it works when I run it as a module:

$ python -m flask run

This is caused as python is looking for a script named flask, but on windows it is called flask.exe.

As a temporary fix you can copy and paste flask.exe, and just rename it ‘flask’

Good call @TomIsPrettyCoool. So this is a bug in the reloader - note that windows finds flask when prompted to, although it’s flask.exe. the werkzeug reloader probably calls flask instead of flask.exe. I imagine there are two ways to solve this: (1) fix the reloader to use flask.exe on windows; (2) add batch file called flask next to flask.exe during flask install. (2) is probably easier and contained in flask, but (1) might solve future bugs for other packages.

If you run into this you can temporarily use python -mflask. I encountered the same thing recently. Need to see what this is. I think it’s that it looks for flask but it should look for flask.exe.