admin管理员组

文章数量:1402059

I am trying to run the following in dockerfile using the ubuntu:latest image, but I am getting an error.

# Use an official Ubuntu base image
FROM ubuntu:latest

# Install Python and dependencies - not really needed as ubuntu:latest has python3 pre-installed
# RUN apt update
# RUN apt install -y python3 python3-pip

# Set working directory
WORKDIR /app

# Copy files into the container
COPY requirements.txt .
COPY main.py .

# Install required Python packages
# RUN python3-pip install -r requirements.txt
RUN pip3 install -r requirements.txt
# RUN python3 -m pip install -r requirements.txt
# RUN pip install -r requirements.txt

# Define entrypoint
ENTRYPOINT ["python3", "main.py"]

I don't know what I have done wrong but I just can't run pip install - even though I have tried all the variations - python3-pip, pip3, python3 -m pip, pip, etc...

Here is an extract of the log:

#7 [2/5] WORKDIR /app
#7 DONE 0.0s
#8 [3/5] COPY requirements.txt .
#8 DONE 0.0s
#9 [4/5] COPY main.py .
#9 DONE 0.0s
#10 [5/5] RUN pip3 install -r requirements.txt
#10 0.162 /bin/sh: 1: pip3: not found
#10 ERROR: process "/bin/sh -c pip3 install -r requirements.txt" did not complete successfully: exit code: 127
------
 > [5/5] RUN pip3 install -r requirements.txt:
0.162 /bin/sh: 1: pip3: not found
------
Dockerfile:17
--------------------
  14 |     
  15 |     # Install required Python packages
  16 |     # RUN python3-pip install -r requirements.txt
  17 | >>> RUN pip3 install -r requirements.txt
  18 |     # RUN python3 -m pip install -r requirements.txt
  19 |     # RUN pip install -r requirements.txt
--------------------
ERROR: failed to solve: process "/bin/sh -c pip3 install -r requirements.txt" did not complete successfully: exit code: 127

本文标签: pythondocker buildpip3 not foundStack Overflow