Mattuys
Mattuys

Reputation: 13

Mariadb in Docker: MariaDB Connector/Python requires MariaDB Connector/C >= 3.2.4, found version 3.1.16

I try the following Dockerfile:

# syntax=docker/dockerfile:1
FROM python:3.11-slim-bullseye
EXPOSE 80
WORKDIR /app
RUN apt-get update && apt-get install -y
RUN apt install gcc libmariadb3 libmariadb-dev libmariadb-dev-compat -y
RUN pip install --upgrade pip
RUN pip install Flask Flask-SQLAlchemy flask-marshmallow marshmallow-sqlalchemy
RUN pip install mariadb==1.0.0
COPY ./back .
CMD [ "python3", "app.py"]

I get this error: MariaDB Connector/Python requires MariaDB Connector/C >= 3.2.4, found version 3.1.16

And when I try with mariadb==1.0.0 I get this error: MariaDB Connector/Python requires MariaDB Connector/C >= 3.1.3, found version 3.1.16

I see the answer to this post Installing MariaDB in Dockercontainer - requires MariaDB Connector/C >= 3.2.4, found version 3.1.16 but doesn't work

Upvotes: 1

Views: 2659

Answers (2)

Mario Hertu
Mario Hertu

Reputation: 26

You need to install the mariadb Connector/C which you can download on the Dockerfile if you do not want to manually run it.

FROM mcr.microsoft.com/devcontainers/python:1-3.12-bullseye

RUN apt-get update && apt-get install -y \
wget \
gcc \
python3-dev \
openssl

RUN wget https://r.mariadb.com/downloads/mariadb_repo_setup

RUN echo 
"30d2a05509d1c129dd7dd8430507e6a7729a4854ea10c9dcf6be88964f3fdc25  
mariadb_repo_setup" \ | sha256sum -c -

RUN chmod +x mariadb_repo_setup

RUN sudo ./mariadb_repo_setup \--mariadb-server-version="mariadb-10.6"

RUN apt-get update && apt-get install -y \
libmariadb3 \
libmariadb-dev

This worked for me when using the mariadb library in my python code

Upvotes: 0

danblack
danblack

Reputation: 14779

Pulling the latest MariaDB Connector/C from MariaDB managed to install with the latests python mariadb:

FROM python:3.11-slim-bullseye
EXPOSE 80
WORKDIR /app
RUN apt-get update && apt-get install -y gcc wget
RUN wget https://dlm.mariadb.com/2678574/Connectors/c/connector-c-3.3.3/mariadb-connector-c-3.3.3-debian-bullseye-amd64.tar.gz -O - | tar -zxf - --strip-components=1 -C /usr
RUN pip install --upgrade pip
RUN pip install Flask Flask-SQLAlchemy flask-marshmallow marshmallow-sqlalchemy
RUN pip install mariadb

The libmariadb-dev packaged by Debian bulleye was too old.

libmariadb3 are client plugins, I'm not sure if you need those.

Upvotes: 6

Related Questions