prakhar1989/docker-curriculum

Docker run command is giving ImportError[BUG]

manishgaur101 opened this issue · 3 comments

I have the same issue, I'm trying to upgrade from python3 3.7 to 3.9.9 right now to see if it helps

update: did not work, although using an venv I was able to at least run the flask app, but not via docker unfortunately.... still looking for answers 👀

Trying to see how to fix it by patching the ImportError here

So because I couldn't get it to work with FROM python:3 I changed it to FROM python:2 and also updated the following in the Dockerfile:

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

Rebuilt the docker and then reran it, and everything worked!

The final code, and I only it seems needed to change the initial FROM line

FROM python:2

# set a directory for the app
WORKDIR /usr/src/app

# copy all the files to the container
COPY . .

# install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# tell the port number the container should expose
EXPOSE 5000

# run the command
CMD ["python", "./app.py"]