[Python] Error: pg_config executable not found in a dockerfile [duplicate]

Discussão em 'Python' iniciado por Stack, Dezembro 17, 2024.

  1. Stack

    Stack Membro Participativo

    I'm getting an issue with psycopg2 when I build the image on Debian machine.

    I have a dockerfile:

    FROM python:3.12-slim
    COPY . /app
    WORKDIR /app
    RUN pip3 install -r requirements.txt
    ENTRYPOINT [ "streamlit","run","main.py","--server.port=8501", "--server.address=0.0.0.0"]


    to generate requirements.txt i run pip list --format=freeze > requirements.txt

    and a part of the requirements.txt:

    ply==3.11
    prometheus_client==0.20.0
    prompt_toolkit==3.0.47
    protobuf==4.25.3
    psutil==6.0.0
    psycopg2==2.9.9
    pure_eval==0.2.3
    pyarrow==16.1.0
    pycparser==2.22
    pydeck==0.8.0
    Pygments==2.18.0


    when I build the image I got this error :

    Getting requirements to build wheel: finished with status 'error'
    18.19 error: subprocess-exited-with-error
    18.19
    18.19 × Getting requirements to build wheel did not run successfully.
    18.19 │ exit code: 1
    18.19 ╰─> [21 lines of output]
    18.19 running egg_info
    18.19 writing psycopg2.egg-info/PKG-INFO
    18.19 writing dependency_links to psycopg2.egg-info/dependency_links.txt
    18.19 writing top-level names to psycopg2.egg-info/top_level.txt
    18.19
    18.19 Error: pg_config executable not found.
    18.19
    18.19 pg_config is required to build psycopg2 from source. Please add the directory
    18.19 containing pg_config to the $PATH or specify the full executable path with the
    18.19 option:
    18.19
    18.19 python setup.py build_ext --pg-config /path/to/pg_config build ...
    18.19
    18.19 or with the pg_config option in 'setup.cfg'.
    18.19
    18.19 If you prefer to avoid building psycopg2 from source, please install the PyPI
    18.19 'psycopg2-binary' package instead.
    18.19
    18.19 For further information please check the 'doc/src/install.rst' file (also at
    18.19 <https://www.psycopg.org/docs/install.html>).
    18.19
    18.19 [end of output]
    18.19
    18.19 note: This error originates from a subprocess, and is likely not a problem with pip.
    18.30 error: subprocess-exited-with-error


    Do you have any idea please why I'm getting this error ?

    thanks

    Continue reading...

Compartilhe esta Página