2

I am trying to learn flask and for the same created a small program. When I try to run it I am getting the below error. flask run Error-

* Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
Usage: flask run [OPTIONS]

Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.

if I try to change the file name to app.py it runs smooth but when the file name is flaskblog.py it isn't working.

I tried setting up the environment variables as suggested in the blog-> How to set environment variables in PyCharm? but nothing worked.

Screenshots attached. content of environment variable file

shows envfile option is checked under flaskblog configuration

environment variable at project level

at python console level

os.environ['FLASK_APP'] output

1
  • To add, if I run the code with print(os.environ['FLASK_APP']) this gives me correct output but the same doesn't work on the terminal Commented May 1, 2020 at 18:43

2 Answers 2

2

Open Settings -> Tools -> Terminal and there set up the environment variable FLASK_APP=app.py. Next, perform restart of PyCharm.

Sign up to request clarification or add additional context in comments.

Comments

1

I was able to resolve this by setting up the environment variable on the terminal itself. set FLASK_APP=flaskblog.py

and then it ran like smoothly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.