![](/img/trans.png)
[英]How to dockerize my flask web app with mysql database?Cannot connect mysql and cannot found render templete
[英]How to dockerize fastText in flask
我写了一个简单的 flask web 服务来使用 fastText 进行预测。 我想将它们放入 docker。 我的 Dockerfile 是这样的:
FROM python:3
WORKDIR /app
COPY . .
RUN pip3 install -r requirements.txt
RUN git clone https://github.com/facebookresearch/fastText.git /tmp/fastText && \
rm -rf /tmp/fastText/.git* && \
mv /tmp/fastText/* / && \
cd / && \
make
CMD ["python", "app.py"]
要求.txt
Flask==0.10.0
docker-compose.yml
version: "3.7"
services:
helloworld:
build:
context: ./
ports:
- 5000:5000
当我运行 docker-compose 时,出现错误:
ModuleNotFoundError: No module named 'fasttext'
如何解决这个问题?
尝试运行这些指令而不是 make 指令:
$ git clone https://github.com/facebookresearch/fastText.git
$ cd fastText
$ pip install .
您必须将 Dockerfile 替换为以下内容:
FROM python:3
WORKDIR /app
COPY . .
RUN pip3 install -r requirements.txt
RUN git clone https://github.com/facebookresearch/fastText.git && \
cd fastText && \
pip install .
CMD ["python", "app.py"]
这样就可以为python构建fastText(如官方文档所示)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.