I'm having a weird issue with Docker.

I'm creating a Docker image using this file:

FROM python:3.11-slim

RUN apt-get update && \
        apt-get install -y git && \
        apt-get install -y libsm6 libxext6 libxrender-dev && \
        apt-get install -y libgl1-mesa-dev && \
        apt-get install -y libgtk2.0

RUN pip3 install --upgrade pip

ARG UNAME=user
ARG UID=1000
ARG GID=1000
RUN groupadd -g $GID -o $UNAME
RUN useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME
USER $UNAME

COPY requirements.txt /tmp/requirements.txt
RUN python -m pip install --user setuptools wheel
RUN python -m pip install --user --no-cache-dir -r /tmp/requirements.txt

and this is my requirements file:

numpy==1.26.4
opencv-python
torch
torchvision
deepdiff==6.7.1

Notice I'm NOT pinning the versions of opencv, torch and torchvision, I'm letting pip solve them.

So, I create the image, run the container interactively, and then from inside the container I checked the versions of the installed opencv, torch and torchvision:

cv2.__version__ -> 4.9.0
torch.__version__ -> 2.2.2+cu121
torchvideo.__version__ -> 0.17.2+cu121

So, I tried using these versions in the requirements.txt file:

numpy==1.26.4
opencv-python==4.9.0
torch==2.2.2+cu121
torchvision==0.17.2+cu121
deepdiff==6.7.1

But then, when rebuilding the image, I got the error:

ERROR: Could not find a version that satisfies the requirement opencv-python==4.9.0 (from versions: 3.4.0.14, 3.4.10.37, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.15.55, 3.4.16.57, 3.4.16.59, 3.4.17.61, 3.4.17.63, 3.4.18.65, 4.3.0.38, 4.4.0.40, 4.4.0.42, 4.4.0.44, 4.4.0.46, 4.5.1.48, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64, 4.6.0.66, 4.7.0.68, 4.7.0.72, 4.8.0.74, 4.8.0.76, 4.8.1.78, 4.9.0.80)
0.998 ERROR: No matching distribution found for opencv-python==4.9.0

And similarly for torch and torchvideo. How is it possible, if they are literally the versions that pip selected when I wasn't pinning them?

I also tried relaxing the version pinning by using ~= for those packages, but I'm still having the same issue.

0

There are 0 best solutions below