我编写了一个简单的flask web服务来使用fastText进行预测。我想把它们放进码头。我的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"]requirements.txt
Flask==0.10.0docker-compose.yml
version: "3.7"
services:
helloworld:
build:
context: ./
ports:
- 5000:5000当我运行docker-compose up时,它出现了一个错误:
ModuleNotFoundError: No module named 'fasttext'如何解决这个问题呢?
发布于 2020-12-14 02:51:26
尝试运行这些指令,而不是make one:
$ git clone https://github.com/facebookresearch/fastText.git
$ cd fastText
$ pip install .发布于 2020-12-14 17:18:39
您必须将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 (如in the official documentation所示)。
https://stackoverflow.com/questions/65276699
复制相似问题