Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.4k views
in Technique[技术] by (71.8m points)

"flask run" doesn't work but "python app.py" does?

This problem has been driving me crazy and I hope that it's okay I'm asking this. It's probably a really dumb question but I've tried looking for a solution for hours and I'm still stuck. I've been following this tutorial https://blog.miguelgrinberg.com/post/how-to-create-a-react--flask-project.

This is the error I'm getting: enter image description here

Basically, when I try to do the command flask run it gives me the error that The system cannot find the file specified. However, when I do python flaskFile.py it does run the application. I have a .flaskenv file that defines FLASK_APP=flaskFile.py and FLASK_ENV=development.

This is what my files look like. The application is in a folder called backend which is inside of a file called DECENT:

enter image description here

In venv there is a Scripts folder where I put the .flaskenv file:

I've tried putting the .flaskenv file in other locations but nothing is working. Thanks in advance, I am super desperate here and I am eternally grateful for any response


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As per screenshot it looks like it is not taking the virtualenv python. It is taking the local python where flask is not installed. Try to switch to venv python then try


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...