1

I built below dockerfile using python image for my python heavy project

FROM python:3.11-slim-buster

# Update and install system packages
RUN apt-get update -y && \
  apt-get install --no-install-recommends -y -q \
  git libpq-dev python-dev && \
  apt-get clean && \
  rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Copy the requirements.txt file
COPY requirements.txt .

# Install Python dependencies using pip
RUN python3.11 -m pip install --no-cache-dir --upgrade pip \
    && python3.11 -m pip install --no-cache-dir -r requirements.txt

EXPOSE 9700

WORKDIR /my_app

requirements.txt include

snowflake-connector-python==3.0.2
DataProflier==0.8.8

When I run this Dockerfile I am getting the error:

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for psutil
Failed to build psutil
ERROR: Could not build wheels for psutil, which is required to install 
pyproject.toml-based projects

Based on the other posts, I tried to lower the python image version/ pip but still I am getting the same error. I observed that I'm only getting this error while installing certain packages from requirements.txt like DataProfiler

Edit:

Even after upgrading the setup tools, I am still getting the below error

#0 10.85       error: command 'gcc' failed: No such file or directory
#0 10.85       [end of output]
#0 10.85   
#0 10.85   note: This error originates from a subprocess, and is likely not a problem with pip.
#0 10.85   ERROR: Failed building wheel for python-snappy
#0 10.85   Running setup.py clean for python-snappy
#0 11.06 Failed to build psutil python-snappy
#0 11.06 ERROR: Could not build wheels for psutil, which is required to install pyproject.toml-based projects
------
failed to solve: executor failed running [/bin/sh -c python3.11 -m pip install --no-cache-dir --upgrade pip && python3.11 -m pip install -U setuptools && python3.11 -m pip install --no-cache-dir -r requirements.txt]: exit code: 1
R0bert
  • 507
  • 6
  • 30
  • this may help https://stackoverflow.com/questions/73329011/use-pip-install-psutil-on-docker-image-python3-9-13-alpine3-16-error-linux-e – deadshot Apr 10 '23 at 03:51

2 Answers2

2

Upgrading the setuptools solved this problem for me.

RUN python3.11 -m pip install --no-cache-dir --upgrade pip \
&& python3.11 -m pip install -U setuptools \
&& python3.11 -m pip install --no-cache-dir -r requirements.txt
Rukon
  • 77
  • 5
0

Solved the above issue by updating the system packages as follows

RUN apt-get update -y && \
  apt-get install --no-install-recommends -y -q \
  git libpq-dev python-dev build-essential libsnappy-dev && \
  apt-get clean && \
  rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
R0bert
  • 507
  • 6
  • 30