0

I was trying to build a docker image of "nestle-acne-assessment", unfortunately, I am facing an issue with the Python3 invalid syntax error.

Here's the Dockerfile:

FROM mcr.microsoft.com/cntk/release:2.5.1-cpu-python3.5
 
RUN dpkg --add-architecture i386 \
&& apt-get update && apt-get install -y \
build-essential \
git \
python3-pip \
python3-tk \
libglib2.0-0:i386 \
&& rm -rf /var/lib/apt/lists/*

RUN pip3 install --upgrade pip
RUN pip3 install -U scikit-learn
RUN pip3 install numpy pandas sklearn matplotlib
RUN pip3 install scipy
RUN pip3 install opencv-python-headless
RUN pip3 install dlib
RUN pip3 install scikit-image
RUN pip3 install matplotlib
RUN pip3 install cntk
RUN pip3 install \
flask \
pillow

RUN mkdir /usr/src/nestle
WORKDIR /workspace
RUN chmod -R a+w /workspace
ADD ../models /workspace/models
COPY main.py /workspace
COPY regressionModel.py /workspace
COPY getPatches.py /workspace
COPY model.py /workspace
RUN chmod +x /workspace/main.py
RUN ls /workspace
CMD python3 /workspace/main.py
 
EXPOSE 9580

The error starts at RUN pip3 install -U scikit-learn.

The error:

 => ERROR [ 4/22] RUN pip3 install -U scikit-learn                                                                 0.6s
------
 > [ 4/22] RUN pip3 install -U scikit-learn:
#7 0.576 Traceback (most recent call last):
#7 0.576   File "/usr/local/bin/pip3", line 7, in <module>
#7 0.576     from pip._internal.cli.main import main
#7 0.576   File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 57
#7 0.576     sys.stderr.write(f"ERROR: {exc}")
#7 0.576                                    ^
#7 0.576 SyntaxError: invalid syntax
------
executor failed running [/bin/sh -c pip3 install -U scikit-learn]: exit code: 1

I already tried to change the architecture to amd64 but it did not resolve the issue.

Please help me. Thank you.

  • [Installing pip is not working in python < 3.6](https://stackoverflow.com/questions/65869296/installing-pip-is-not-working-in-python-3-6) suggests a newer Python might help you. The current version is Python 3.10; can you use that version instead of the somewhat old 3.5? – David Maze Jan 23 '22 at 02:53
  • Hi @DavidMaze. I upgraded the pip to a specific release. The build worked. Thank you. – Hanson Deck Jan 23 '22 at 03:33

1 Answers1

0

I was able to build the docker image by upgrading the pip to a specific version, pip==19.3.1.

RUN pip3 install --upgrade pip==19.3.1

Why 19.3.1? Because the GitHub repo hasn't been updated since 2019.

Thank you for the help, David Maze.