microsoft / python-sample-vscode-flask-tutorial

Sample code for the Flask tutorial in the VS Code documentation
https://code.visualstudio.com/docs/python/tutorial-flask
MIT License
349 stars 5.14k forks source link

issue in __init__.py #44

Open Nefilime opened 3 years ago

Nefilime commented 3 years ago

I build image via dockerfile

When container start i see error in container.

Traceback (most recent call last): File "./hello_app/init.py", line 1, in from flask import Flask # Import the Flask class ModuleNotFoundError: No module named 'flask' unable to load app 0 (mountpoint='') (callable not found or import error) no app loaded. GAME OVER

chinghwayu commented 2 years ago

I know this is a year late but I just ran into this and resolved by changing the base image (which doesn't include flask) to:

tiangolo/uwsgi-nginx-flask:python3.8-alpine-2020-12-19

https://github.com/microsoft/python-sample-vscode-flask-tutorial/blob/c49c02d17ce0631f4fc1e1d87f4de69deca3ec26/Dockerfile#L2

yorkzhang commented 2 years ago

The issue seems happen again even "tiangolo/uwsgi-nginx-flask:python3.8-alpine-2020-12-19" is already changed to. It looks like the new image from Dockerhub was not built properly so Flask is not installed in. An easy way is just uncommenting below lines in Dockerfile:

COPY requirements.txt /

RUN pip install --no-cache-dir -U pip

RUN pip install --no-cache-dir -r /requirements.txt