Error pip install mariadb on ubuntu server

Viewed 4248

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?

5 Answers

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.

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

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

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 untaring 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/
Related