You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
python debug with docker-compose in vscode: Error: Could not locate a Flask application. Use the 'flask --app' option, 'FLASK_APP' environment variable, or a 'wsgi.py' or 'app.py' file in the current directory
#1966
Open
yezhengli-Mr9 opened this issue
Dec 31, 2023
· 1 comment
docker-compose up flask-dev
Starting demo-cookiecutter-flask_flask-dev_1 ... done
Attaching to demo-cookiecutter-flask_flask-dev_1
flask-dev_1 |
flask-dev_1 | > my_flask_app@1.0.0 start
flask-dev_1 | > python -m debugpy --wait-for-client --listen 0.0.0.0:5678 -m flask run --host=0.0.0.0
flask-dev_1 |
flask-dev_1 | 0.00s - Debugger warning: It seems that frozen modules are being used, which may
flask-dev_1 | 0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
flask-dev_1 | 0.00s - to python to disable frozen modules.
flask-dev_1 | 0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
flask-dev_1 | Usage: python -m flask run [OPTIONS]
flask-dev_1 | Try 'python -m flask run --help' for help.
flask-dev_1 |
flask-dev_1 | Error: Could not locate a Flask application. Use the 'flask --app' option, 'FLASK_APP' environment variable, or a 'wsgi.py' or 'app.py' file in the current directory.
demo-cookiecutter-flask_flask-dev_1 exited with code 2
Project configuration:
Option
Values
use_pipenv
yes
no
python_version
3.11
3.10
3.9
3.8
node_version
20
18
node -v v12.22.9; npm -v 8.5.1
use_heroku
yes
no
Are you using Docker to run the app?
yes
no
The text was updated successfully, but these errors were encountered:
Thanks @jamescurtin for steps in https://medium.com/@lassebenninga/how-to-debug-flask-running-in-docker-compose-in-vs-code-ef37f0f516ee
I try to follow steps there to get familiar with python debug with docker-compose in vscode j2eeexpert2015/springbootdebug#1
debugpy
library to yourDockerfile
EXPOSE 2992 EXPOSE 5000 ++ RUN pip install debugpy CMD [ "npm", "start"]
https://github.com/jamescurtin/demo-cookiecutter-flask/blob/ef61ca4503c9a9c4de338034d94ba385afc34958/Dockerfile#L54-L56
debugpy
command to the launch scriptin https://github.com/jamescurtin/demo-cookiecutter-flask/blob/ef61ca4503c9a9c4de338034d94ba385afc34958/package.json#L9
launch.json
so result exact same file:5678
indocker-compose.yml
services: flask-dev: build: context: . target: development args: <<: *build_args image: "my_flask_app-development" ports: - "8080:5000" - "2992:2992" ++ - "5678:5678" <<: *default_volumes
https://github.com/jamescurtin/demo-cookiecutter-flask/blob/ef61ca4503c9a9c4de338034d94ba385afc34958/docker-compose.yml#L13-L24
and then
Project configuration:
use_pipenv
yes
no
python_version
3.11
3.10
3.9
3.8
node_version
20
18
node -v v12.22.9; npm -v 8.5.1
use_heroku
yes
no
yes
no
The text was updated successfully, but these errors were encountered: