python mariadb pip安装失败,缺少mariadb\u配置

7qhs6swi  于 2021-07-24  发布在  Java
关注(0)|答案(3)|浏览(510)

我使用的是linux Ubuntu18.04和Python3。我正在尝试在mariadb和python脚本之间建立连接。因此,我必须安装mariadb包。
我已经安装了:

sudo apt install mariadb-server

但当我尝试时:

pip install mariadb

我得到以下错误:

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.

有人能帮我吗?
编辑:
我现在已经能够连接到服务器,但不能与te mariadb包(https://linuxhint.com/connect_mariadb_pymysql/)

yuvru6vn

yuvru6vn1#

要安装mariadb python模块,您必须安装mariadb connector/c的最新版本,最低要求版本是3.1.5,afaik ubuntu 18.04有3.0.3。
mariadb connector/c下载页上提供了用于bionic的connector/c的实际版本。
如果要将其安装在特殊目录中,请确保path和ld\u library\u path指向bin和lib目录。
我还建议使用最新版本的mariadb server,特别是在mariadb server<10.2上,非常快的executemany()方法会慢得多。

kqqjbcuj

kqqjbcuj2#

安装mariadb connector/c,这是一个依赖项。

sudo apt-get install libmariadb3 libmariadb-dev

使用pip安装mariadb connector/python。

pip3 install mariadb
nhhxz33t

nhhxz33t3#

似乎你需要先在你的操作系统上安装它。您可以按照本指南正确安装。

相关问题