I wrote a simple flask web service to use fastText to do the prediction. I want to put them into docker. My Dockerfile is like this:
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
When I run the docker-compose up, it comes with an error:
ModuleNotFoundError: No module named 'fasttext'
How to do fix that?
Try running those instructions instead of the make one:
$ git clone https://github.com/facebookresearch/fastText.git
$ cd fastText
$ pip install .
You have to replace your Dockerfile with the following:
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"]
In this way, you can build fastText for python (as shown in the official documentation ).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.