gpt4 book ai didi

python - Docker Flask ModuleNotFoundError : No module named 'flask'

转载 作者:行者123 更新时间:2023-12-03 16:17:58 40 4
gpt4 key购买 nike

执行时出现以下错误

docker-compose up --build


web_1  | Traceback (most recent call last):
web_1 | File "glm-plotter.py", line 4, in <module>
web_1 | from flask import Flask, render_template, request, session
web_1 | ModuleNotFoundError: No module named 'flask'
glm-plotter_web_1 exited with code 1

我尝试在 requirements.txt 中将“Flask”更改为“flask”

文件
FROM continuumio/miniconda3
RUN apt-get update && apt-get install -y python3
RUN apt-get install -y python3-pip
RUN apt-get install -y build-essential

COPY requirements.txt /
RUN pip3 install --trusted-host pypi.python.org -r /requirements.txt

ADD ./glm-plotter /code
WORKDIR /code
RUN ls .
CMD ["python3", "glm-plotter.py"]

docker-compose.yml
version: "3"
services:
web:
volumes:
- ~/.aws:/root/.aws
build: .
ports:
- "5000:5000"

要求.txt
click==6.6
Flask==0.11.1
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
numpy==1.11.1
pandas==0.18.1
python-dateutil==2.5.3
pytz==2016.4
six==1.10.0
Werkzeug==0.11.10

glm-plotter.py
from flask import Flask, render_template, request, session
import os, json
import GLMparser
...

最佳答案

我创建了一个 Docker,它编译得很好。您可能希望根据您的个人需求调整它并添加 Dockerfile 中的最后几行。以上:

FROM library/python:3.6-stretch

COPY requirements.txt /
RUN pip install -r /requirements.txt

请注意,在 library/python图像没有明确的版本号 pythonpip是必需的,因为只安装了一个。

关于python - Docker Flask ModuleNotFoundError : No module named 'flask' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52603324/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com