I've been trying to follow a few tutorials and start a flask project inside a pipenv environment. I can't seem to point my export FLASK_APP=<-app.py location-> to the right location.
I start the project with pipenv install flask
I verified that python is working inside the environment:
If I put the app.py in the main VENV folder, I can point to it with export FLASK_APP=app.py
and run pipenv run flask run
and everything works fine.
I then create a folder called flask, with __init__.py
and app.py
.
I then try and export the FLASK_APP and run pipenv run flask run
export FLASK_APP=/flask/app.py
does not work
export FLASK_APP=./flask/app.py
does not work
export FLASK_APP=$VIRTUAL_ENV/../flask/app.py
does not work
I can't even see the folder when I look in $VIRTUAL_ENV/
. I just see bin/ include/ lib/ src/
This has got to be something simple that I am missing. Any thoughts?
pip
and pipenv
commands.here are steps to create flask app in pipenv
mkdir <project_root>
make new folder for projectcd <test_flask_app>
go into new folderpipenv --three
create new virtual environment using with python 3 pipenv shell
activate pipenv virtual environmentpipenv install flask
install flaskmkdir <python_code_root>
create folder for all python code (see here for example python project https://github.com/kennethreitz/samplemod)create simple flask app file <python_code_root>/app.py
(taken from http://flask.pocoo.org/)
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
the expected project folder should look like
.
├── Pipfile
├── Pipfile.lock
└── <python_code_root>
└── app.py
export FLASK_APP=<python_code_root>/app.py
export variable
flask run
start flask appNote that pipenv --three
generates the python virtual env folder in a random hashed folder. You're not supposed to manually edit/add anything in this folder.
When I run pipenv --three
the output is:
Creating a virtualenv for this project…
Pipfile:
/Users/grahamcrowell/Documents/test_flask_app/Pipfile
Using /usr/local/bin/python3 (3.7.1) to create virtualenv…
✔ Complete
Using base prefix '/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/grahamcrowell/.local/share/virtualenvs/test_flask_app-l4aYsVUB/bin/python3.7
Also creating executable in /Users/grahamcrowell/.local/share/virtualenvs/test_flask_app-l4aYsVUB/bin/python
Installing setuptools, pip, wheel...done.
Running virtualenv with interpreter /usr/local/bin/python3
Virtualenv location: /Users/grahamcrowell/.local/share/virtualenvs/test_flask_app-l4aYsVUB
Creating a Pipfile for this project…