=> ERROR [ 4/22] RUN pip3 install -U scikit-learn

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 \

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

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.

1 answer

  • answered 2022-01-23 03:35 Hanson Deck

    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.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum