Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with pip install mariadb - mariadb_config not found

I have been trying to run pip3 install mariadb on my raspberry pi running ubuntu 18.04 and I was unsuccessful.

I have tried installing following packages as suggested in other answers:

sudo apt-get install mariadb-server
sudo apt-get install libmariadbclient-dev
sudo apt-get install libmysqlclient-dev

pip3 install mysqlclient
pip3 install mysql-connector-python-rf

However, I'm still running intto the problem as shown:

ubuntu@ubuntu:~$ pip3 install mariadb
Collecting mariadb
  Using cached https://files.pythonhosted.org/packages/8f/c9/7050899dc1066409a17e1147d3afe1b078e582afdb755c6d3cb9c9a5c3ab/mariadb-1.0.0.tar.gz
    Complete output from command python setup.py egg_info:
    /bin/sh: 1: mariadb_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-2gdw_t_r/mariadb/setup.py", line 26, in <module>
        cfg = get_config(options)
      File "/tmp/pip-build-2gdw_t_r/mariadb/mariadb_posix.py", line 49, in get_config
        cc_version = mariadb_config(config_prg, "cc_version")
      File "/tmp/pip-build-2gdw_t_r/mariadb/mariadb_posix.py", line 27, in mariadb_config
        "mariadb_config not found.\nPlease make sure, that MariaDB Connector/C is installed on your system, edit the configuration file 'site.cfg' and set the 'mariadb_config'\noption, which should point to the mariadb_config utility.")
    OSError: mariadb_config not found.
    Please make sure, that MariaDB Connector/C is installed on your system, edit the configuration file 'site.cfg' and set the 'mariadb_config'
    option, which should point to the mariadb_config utility.
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-2gdw_t_r/mariadb/

I do have /etc/mysql/my.cnf file.

like image 635
Alex Xu Avatar asked Jul 22 '20 04:07

Alex Xu


People also ask

How do I install MariaDB Python connector?

Install from Source Distribution Install MariaDB Connector/C, which is a dependency. Ensure that that prerequisites for source distributions are met. Download a source tarball for a supported MariaDB Connector/Python 1.1 or MariaDB Connector/Python 1.0 release. Extract the source tarball.

How does MariaDB connect to Python?

To establish a connection to MariaDB from Python, you should first import the MariaDB connector. This should be done using Python's import statement. Next, you should call the connect() function to establish a connection to your MariaDB database of choice.


1 Answers

You probably need to install MariaDB database development files: https://packages.debian.org/unstable/libmariadb-dev. You need this package for your python connector to work properly in linux. You need to follow this steps:

  1. sudo apt-get update -y
  2. sudo apt-get install -y libmariadb-dev
  3. pip3 install mariadb

Here you are first updating the list of packages that need an upgrade for your system. Then you are installing the previously mentioned dev library. The last step is to install mariadb with pip3 which should now work as expected.

like image 144
Pablompg Avatar answered Nov 02 '22 19:11

Pablompg