Flask: Application did not run with `flask run` with FLASK_DEBUG=1(But can run by using command`python -m flask run`) in Win10

Created on 13 Nov 2016  路  8Comments  路  Source: pallets/flask

Error message:
d:\projects\cfblog2_env\scripts\python.exe: can't open file 'D:\projects\cfblog2_env\Scripts\flask': [Errno 2] No such file or directory

Environment: Win 10, Py 3.5.2(VirtualEnv)锛孎lask 0.11
This error was came from '_reload.py' in werkzeug.It seems like when run with flask.exe, sys.executable still equal to python's exe path and sys.argv is something like this:'D:\\projects\\cfblog2_env\\Scripts\\flask', 'run'

I am not sure what cause this problem actually(werkzeug,packer of flask.exe or flask itself).But this error happend when I using flask. So I put the issuse here.

To whom has the same error, you can usepython -m flask run for workaround.
And last, sorry for my poor english.

Most helpful comment

@untitaker
Yes, both ways(python -m flask run or flask run) work when not using FLASK_DEBUG=1.
@wgwz @saalaa
Sure I did.And as I said before, this didn't work only when I use flask run and set the debug flag 1.

All 8 comments

did you set FLASK_APP=.py?

It seems it can't find flask; which leads me to believe you either have not installed flask or you haven't activated your virtual environment.

To activate your virtual environment:

$ virtualenv env
$ source env/bin/activate

To install flask:

$ pip install flask

Hardly a bug.

Edit: misread, disregard my answer. It indeed looks like a bug figuring out flask's path.

@future0906 does it work when not using debug mode?

@untitaker
Yes, both ways(python -m flask run or flask run) work when not using FLASK_DEBUG=1.
@wgwz @saalaa
Sure I did.And as I said before, this didn't work only when I use flask run and set the debug flag 1.

@future0906 Create a copy of flask.exe and rename it "flask" without the extension. This is a temporary fix.

@untitaker Is this issue similar to #1829?

Yes, appears to be a dupe

Error message:
d:\projects\cfblog2_env\scripts\python.exe: can't open file 'D:\projects\cfblog2_env\Scripts\flask': [Errno 2] No such file or directory

Environment: Win 10, Py 3.5.2(VirtualEnv)锛孎lask 0.11
This error was came from '_reload.py' in werkzeug.It seems like when run with flask.exe, sys.executable still equal to python's exe path and sys.argv is something like this:'D:\\projects\\cfblog2_env\\Scripts\\flask', 'run'

I am not sure what cause this problem actually(werkzeug,packer of flask.exe or flask itself).But this error happend when I using flask. So I put the issuse here.

To whom has the same error, you can usepython -m flask run for workaround.
And last, sorry for my poor english.

THANK YOU!!!! I've been trying to get this to work for almost a week, no one could help. Also, your English is great!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KeyC0de picture KeyC0de  路  4Comments

maangulo12 picture maangulo12  路  4Comments

runfalk picture runfalk  路  4Comments

ghostbod99 picture ghostbod99  路  4Comments

greyli picture greyli  路  3Comments