Kumar
Kumar

Reputation: 11

flask not found in Docker

In the Docker file, I get this error ImportError: No module named flask

Here is the Docker file

FROM continuumio/anaconda3
MAINTAINER kumar
COPY ./flask_master /usr/local/python
EXPOSE 5000
WORKDIR /usr/local/python
RUN apt-get update && apt-get install -y python3-pip 
RUN pip3 install -r requirements.txt
CMD python flaskPredictAPI.py

Here is the requirements.txt

flask
flasgger
joblib

But when I run it, I get this

docker run -i -t -p 5000:5000 randomforestapi

Traceback (most recent call last): File "flaskPredictAPI.py", line 1, in from flask import Flask, request ImportError: No module named flask

Upvotes: 1

Views: 425

Answers (1)

rajeev
rajeev

Reputation: 41

Are you able to build your docker image successfully? Did you checked if during build the requirements.txt gets executed without any error? I would suggest you generate your requirements.txt using below command in your project folder.

pip freeze > requirements.txt

It would look something like this

click==7.1.2
Flask==1.1.2
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
Werkzeug==1.0.1

Upvotes: 0

Related Questions