Arpit Rathod
Arpit Rathod

Reputation: 101

setting environment variable in pycharm?

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

Upvotes: 2

Views: 9272

Answers (2)

psota
psota

Reputation: 21

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

Upvotes: 2

Arpit Rathod
Arpit Rathod

Reputation: 101

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.

Upvotes: 1

Related Questions