Reputation: 402
I was following this documentation on directory management for Flask projects. Now, I'm trying to run my flask application from PyCharm. I have added the below mentioned Environment Variables in Edit Configurations...
:
FLASK_DEBUG=true
FLASK_APP=<absolute-path-to-root-directory-of-application>
I add the Script
as flask run
The output running this configuration is this:
../red-flask/venv/bin/python "flask run"
../red-flask/venv/bin/python: can't open file 'flask run': [Errno 2] No such file or directory
Process finished with exit code 2
My project directory looks like:
/flask_app
setup.py
/flask_app
__init__.py
views.py
/static
style.css
/templates
layout.html
index.html
login.html
...
I am unable to figure out how to make this work, any help is appreciated.
Upvotes: 12
Views: 18720
Reputation: 127180
This is documented in the development build of the docs.
You need to point to the location of the flask
command.
/path/to/env/bin/flask
run
Until 1.0 comes out, you need to point FLASK_APP
at __init__.py
if you don't install your package in your env.
FLASK_APP
/path/to/flask_app/__init__.py
Preferably, install the package in the env and point to it using the import name.
pip install -e .
FLASK_APP
flask_app
Upvotes: 14