2

I'm trying to create a container for my python project that uses mariaDB. Here there are dockerfile's lines related to the problem:

FROM python:3.10.6-slim-buster

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update  && \
    apt-get install -yq apt-utils && \
    apt-get install -yq procps && \
    apt-get install -yq nano && \
    apt-get install -yq libmariadb3 libmariadb-dev
RUN rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir -r requirements.txt

In my requirements.txt I have:

mariadb==1.1.4

When I run the docker build it returns me this error:

Collecting mariadb==1.1.4
  Downloading mariadb-1.1.4.zip (97 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.4/97.4 kB 10.8 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-2uzbllpk/mariadb_4588dbf4d5fc48b989ebd2605c2d7d1c/setup.py", line 27, in <module>
          cfg = get_config(options)
        File "/tmp/pip-install-2uzbllpk/mariadb_4588dbf4d5fc48b989ebd2605c2d7d1c/mariadb_posix.py", line 64, in get_config
          print('MariaDB Connector/Python requires MariaDB Connector/C '
      TypeError: not enough arguments for format string
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

As you can see, I installed the required packages for the connector via apt-get, the installation works without error, but I am still having this problem.

Do you have any idea?

Thank you.

Codename47
  • 295
  • 4
  • 17
  • This seems to happen because the python connector wants a specific version of the c connector, but due to a coding error is unable to tell you which. [This answer](https://stackoverflow.com/a/73074751/5320906) may help. – snakecharmerb Aug 14 '22 at 11:55
  • It doesn't work anyway, I receive the same error. – Codename47 Aug 14 '22 at 16:29

1 Answers1

2

Sorry, my bad - When formatting the code in 1.1.4 with Flake8 (PEP-8) the brackets around the tuple accidentally disappeared, this is already fixed in 1.1.5 (not released yet)

Minimum required Connector/C version is 3.2.4. Buster has MariaDB Server 10.3, corresponding C/C version is 3.1.x - so instead of buster you should bookworm (Server version 10.6.8, C/C version 3.2.8).

Georg Richter
  • 5,970
  • 2
  • 9
  • 15