简体   繁体   English

Python MariaDB pip 安装失败,缺少 mariadb_config

[英]Python MariaDB pip install failed, missing mariadb_config

I am using Linux Ubuntu 18.04 and python 3. I am trying to build a connection between a maria-db and my python scripts. I am using Linux Ubuntu 18.04 and python 3. I am trying to build a connection between a maria-db and my python scripts. Therefore I have to install the mariadb package.因此我必须安装 mariadb package。
I have already installed:我已经安装了:

sudo apt install mariadb-server

But when i try:但是当我尝试时:

pip install mariadb

I get following error:我收到以下错误:

Collecting mariadb
  Using cached mariadb-1.0.0.tar.gz (78 kB)

    ERROR: Command errored out with exit status 1:
     command: /home/niklas/Desktop/Stuff/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pycharm-packaging/mariadb/setup.py'"'"'; __file__='"'"'/tmp/pycharm-packaging/mariadb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-wfnscxnz
         cwd: /tmp/pycharm-packaging/mariadb/
    Complete output (12 lines):
    /bin/sh: 1: mariadb_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pycharm-packaging/mariadb/setup.py", line 26, in <module>
        cfg = get_config(options)
      File "/tmp/pycharm-packaging/mariadb/mariadb_posix.py", line 49, in get_config
        cc_version = mariadb_config(config_prg, "cc_version")
      File "/tmp/pycharm-packaging/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.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Can anybody help me?有谁能够帮我?

Edit:编辑:

I have now been able to connect to the server but not with te mariadb package.我现在已经能够连接到服务器,但不能使用 te mariadb package。 ( https://linuxhint.com/connect_mariadb_pymysql/ ) https://linuxhint.com/connect_mariadb_pymysql/

Install MariaDB Connector/C, which is a dependency.安装 MariaDB Connector/C,这是一个依赖项。

sudo apt-get install libmariadb3 libmariadb-dev

Use PIP to install MariaDB Connector/Python.使用 PIP 安装 MariaDB 连接器/Python。

pip3 install mariadb

To install mariadb python module, you have to install a recent version of MariaDB Connector/C, minimum required version is 3.1.5, afaik Ubuntu 18.04 has 3.0.3. To install mariadb python module, you have to install a recent version of MariaDB Connector/C, minimum required version is 3.1.5, afaik Ubuntu 18.04 has 3.0.3.

An actual version of Connector/C for bionic is available on the MariaDB Connector/C Download Page . MariaDB 连接器/C 下载页面上提供了用于仿生的连接器/C 的实际版本。

If you want to install it in a special directory, make sure that the PATH and LD_LIBRARY_PATH point to bin and lib directories.如果要将其安装在特殊目录中,请确保 PATH 和 LD_LIBRARY_PATH 指向 bin 和 lib 目录。

I also recommend to use a recent version of MariaDB Server, especially the very fast executemany() method will be much slower on MariaDB Server < 10.2.我还建议使用最新版本的 MariaDB Server,尤其是非常快的 executemany() 方法在 MariaDB Server < 10.2 上会慢得多。

It seems you need to install it first on your OS.看来您需要先在操作系统上安装它。 You can follow this guide to install it properly.您可以按照本指南正确安装它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM