Reputation: 563
I try to install the mariadb module with pip install mariadb
but it error like this.
Collecting mariadb
Using cached https://files.pythonhosted.org/packages/15/73/250a30543f9987af2e3f7856f29917fa22580cd6b457b8e2df0d6d80b3f3/mariadb-1.0.1.tar.gz
Complete output from command python setup.py egg_info:
MariaDB Connector/Python requires MariaDB Connector/C >= 3.1.5, found version 3.0.3
----------------------------------------
Command "python setup.py egg_info" failed with error code 2 in /tmp/pip-build-f3yri8cs/mariadb/
And what i have try is run pip install --upgrade setuptools
then pip install mariadb
but it still not working, so how can i fix the problem?
Upvotes: 4
Views: 15113
Reputation: 3797
Building mariadb connector from source (v3.3.1).
wget https://archive.mariadb.org//connector-c-3.3.1/mariadb-connector-c-3.3.1-src.zip
unzip mariadb-connector-c-3.3.1-src.zip
cd mariadb-connector-c-3.3.1-src/
mkdir build
cd build/
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local
make
sudo make install
Now pip install should run without any errors.
sudo pip3 uninstall mariadb
sudo pip3 install mariadb
Note that pip3 install mariadb
may pass even when the connector dependency isn't satisfied, hence uninstall it first via pip3 uninstall mariadb
Sometimes the prebuilt binaries may not be available for the version and platform configuration you want.
OS: Raspbian 11 (bulls eye) aarch64
for Raspberry PI
For x86 or x64 architectures, you can simply get prebuilt binaries, as explained here.
You can get source code for a particular connector version here. You may have to select the checkbox for displaying older releases if the release you are looking for isn't being shown.
Upvotes: 2
Reputation: 141
I found the solution for this problem: So, to run pip install mariadb, I followed these steps:
I'm using python3.9, instead of olders versions,
Installing Python 3.9:
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.9
Installing Pip3:
sudo apt install python3-pip
Adding repo of mariadb:
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
If you receive some problens with apt-transport-https, install this:
sudo apt-get install -y apt-transport-https
Run these updates:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
Now, you can install the newest Connector/c:
sudo apt-get install libmariadb3
sudo apt-get install libmariadb-dev
Finally, you can run:
sudo pip3 install mariadb
Should work just fine, sorry for the long post.
Upvotes: 14
Reputation: 5166
First, remove the followings:
sudo apt purge libmariadb3
sudo apt purge libmariadb-dev
(It seems removing one also removes another.)
After downloading MariaDB Connector/C and untar
ing it, you can find three directories; bin
, include
, and lib
. They get what you need to pip install
.
If you try pip install mariadb
before you do the followings, you will figure out what to put where by yourself, as I did.
What I figured out is:
sudo mv -f bin/mariadb_config /usr/bin/
sudo mv -f include/mariadb /usr/local/include/
sudo mv -f lib/mariadb /usr/local/lib/
Now you may pip install mariadb
, however, you may not import mariadb
.
Then, you need:
export LD_LIBRARY_PATH=/usr/local/lib/mariadb/
Upvotes: 1
Reputation: 156
As others have said the version in ubuntu:18.04 isnt recent enough.
I got this working in bionic.
mkdir -p /tmp/mdbccbin
cd /tmp/mdbccbin
curl -O https://downloads.mariadb.com/Connectors/c/connector-c-3.1.10/mariadb-connector-c-3.1.10-ubuntu-bionic-amd64.tar.gz
echo "1b5b513f44967efadf5eae5e34952cd61f94655575d45b5a9182ea1b91d1d1fa mariadb-connector-c-3.1.10-ubuntu-bionic-amd64.tar.gz" | sha256sum -c
# get root
sudo su
tar xvf mariadb-connector-c-3.1.10-ubuntu-bionic-amd64.tar.gz --directory /usr --strip-components 1
echo "/usr/lib/mariadb/" > /etc/ld.so.conf.d/mariadb.conf
ldconfig
# back to regular user
exit
python3 -m pip install --user mariadb
Upvotes: 4
Reputation: 7516
You need to install a newer version of MariaDB Connector/C. Since you have an older ubuntu version (which doesn't provide an actual version of MariaDB Connector/C) you need to download it from MariaDB website.
Since MariaDB Connector/C 3.1.8 MariaDB provides also binary packages for non EOLed Ubuntu platforms. Actual version is 3.1.9 and can be downloaded here
Upvotes: 2
Reputation: 723
MariaDB Connector/Python requires MariaDB Connector/C >= 3.1.5, found version 3.0.3
Install the correct version of the MariaDB Connector/C
https://downloads.mariadb.org/connector-c/3.1.5/
Upvotes: 3