【问题标题】:How to dockerize fastText in flask如何在烧瓶中停靠 fastText
【发布时间】:2020-12-13 14:25:54
【问题描述】:

我编写了一个简单的烧瓶网络服务来使用 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.0

docker-compose.yml

version: "3.7"

services:
  helloworld:
    build:
      context: ./
    ports:
      - 5000:5000

当我运行 docker-compose up 时,它会出现错误:

ModuleNotFoundError: No module named 'fasttext'

如何解决这个问题?

【问题讨论】:

  • 尝试将 RUN pip3 install -r requirements.txt 改为 RUN pip install -r requirements.txt

标签: python docker flask fasttext


【解决方案1】:

尝试运行这些指令而不是 make 指令:

$ git clone https://github.com/facebookresearch/fastText.git
$ cd fastText
$ pip install .

【讨论】:

    【解决方案2】:

    您必须将 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)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-30
      • 2013-07-27
      • 1970-01-01
      • 2014-07-23
      • 2012-06-16
      相关资源
      最近更新 更多