Bootstrap FreeKB - Docker - Resolve "MariaDB Connector/Python requires MariaDB Connector/C"
Docker - Resolve "MariaDB Connector/Python requires MariaDB Connector/C"

Updated:   |  Docker articles

Let's say something like this is being returned when attempting to create a Docker image that contains MariaDB.

MariaDB Connector/Python requires MariaDB Connector/C >= 3.3.1, found version 3.1.20

 

Perhaps your Dockerfile has something like this.

FROM tiangolo/uwsgi-nginx-flask:python3.11
RUN pip install --upgrade pip
pip install mariadb

 

And use the docker build command to create an image using the Dockerfile.

sudo docker build --tag mariadb:latest .

 

You can try using pip3 in your Dockerfile.

FROM tiangolo/uwsgi-nginx-flask:python3.11
RUN pip3 install --upgrade pip
pip3 install mariadb

 

You can try including the libmariadb packages in your Dockerfile.

FROM tiangolo/uwsgi-nginx-flask:python3.11
RUN pip3 install --upgrade pip
RUN apt-get update -y
RUN apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
RUN curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash
RUN apt-get install -y libmariadb-dev
RUN apt-get install -y libmariadb3
pip3 install mariadb

 

If the error persists, there should be a line that shows the version of MariaDB being installed.

Collecting mariadb
  Downloading mariadb-1.1.6.tar.gz (83 kB)

 

You can try installing some other version of MariaDB in your Dockerfile.

FROM tiangolo/uwsgi-nginx-flask:python3.11
RUN pip3 install --upgrade pip
pip3 install mariadb==1.0.11

 

If these easy fixes don't work, then you can always manually download and extract the MariaDB connector.

FROM tiangolo/uwsgi-nginx-flask:python3.11

# ----------------------------------------------------
# make a temporary directory for the MariaDB Connector
# ----------------------------------------------------
RUN mkdir /tmp/connector

# ---------------------------------------------------------------------
# use wget to download the MariaDB Connector to the temporary directory
# ---------------------------------------------------------------------
RUN wget https://downloads.mariadb.com/Connectors/c/connector-c-3.3.5/mariadb-connector-c-3.3.5-ubuntu-bionic-amd64.tar.gz --directory /tmp/connector

# -----------------------------------------------------------------------------------------
# use tar to extract the MariaDB Connector that you downloaded into the temporary directory
# -----------------------------------------------------------------------------------------
RUN tar -zxpf /tmp/connector/mariadb-connector-c-3.3.5-ubuntu-bionic-amd64.tar.gz --directory /tmp/connector

# --------------------------------
# move files
# --------------------------------
RUN mv -f /tmp/connector/mariadb-connector-c-3.3.5-ubuntu-bionic-amd64/bin/mariadb_config /usr/bin/
RUN mv -f /tmp/connector/mariadb-connector-c-3.3.5-ubuntu-bionic-amd64/include/mariadb /usr/local/include/
RUN mv -f /tmp/connector/mariadb-connector-c-3.3.5-ubuntu-bionic-amd64/lib/mariadb /usr/local/lib/

# --------------------------
# use pip to install mariadb
# --------------------------
pip install mariadb

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 3f15bd in the box below so that we can be sure you are a human.