pip 安装 mariadb mac

问题描述 投票:0回答:2

我想通过 Python 连接到 Web 应用程序的 MariaDB 数据库,但似乎无法安装

mariadb
包。我正在使用 Python 3.7.9 运行 Mac。这是我尝试运行
pip install mariadb
时得到的结果是:

Collecting mariadb
  Using cached mariadb-1.0.11.zip (85 kB)
Using legacy setup.py install for mariadb, since package 'wheel' is not installed.
Installing collected packages: mariadb
    Running setup.py install for mariadb ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/.../bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/yz/_pkhkb0x2xb233lq1n0v193r0000gp/T/pip-install-yeefaepy/mariadb/setup.py'"'"'; __file__='"'"'/private/var/folders/yz/_pkhkb0x2xb233lq1n0v193r0000gp/T/pip-install-yeefaepy/mariadb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/yz/_pkhkb0x2xb233lq1n0v193r0000gp/T/pip-record-ock6ntv0/install-record.txt --single-version-externally-managed --compile --install-headers /Users/.../include/site/python3.7/mariadb
         cwd: /private/var/folders/yz/_pkhkb0x2xb233lq1n0v193r0000gp/T/pip-install-yeefaepy/mariadb/
    Complete output (46 lines):
    10.6.8
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-3.7
    creating build/lib.macosx-10.9-x86_64-3.7/mariadb
    copying mariadb/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/mariadb
    creating build/lib.macosx-10.9-x86_64-3.7/mariadb/constants
    copying mariadb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/mariadb/constants
    copying mariadb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.7/mariadb/constants
    copying mariadb/constants/INDICATOR.py -> build/lib.macosx-10.9-x86_64-3.7/mariadb/constants
    copying mariadb/constants/CURSOR.py -> build/lib.macosx-10.9-x86_64-3.7/mariadb/constants
    copying mariadb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-3.7/mariadb/constants
    running build_ext
    building 'mariadb._mariadb' extension
    creating build/temp.macosx-10.9-x86_64-3.7
    creating build/temp.macosx-10.9-x86_64-3.7/mariadb
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/.../include -arch x86_64 -I/Users/MitchPudill/opt/anaconda3/include -arch x86_64 -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=0 -DPY_MARIADB_PATCH_VERSION=11 -I/usr/local/Cellar/mariadb-connector-c/3.3.1/include/mariadb -I/usr/local/Cellar/mariadb-connector-c/3.3.1/include/mariadb/mysql -I./include -I/Users/.../include -I/Users/.../opt/anaconda3/include/python3.7m -c mariadb/mariadb.c -o build/temp.macosx-10.9-x86_64-3.7/mariadb/mariadb.o -DDEFAULT_PLUGINS_SUBDIR="/usr/local/Cellar/mariadb-connector-c/3.3.1/lib/mariadb/plugin"
    In file included from mariadb/mariadb.c:21:
    ./include/mariadb_python.h:75:2: error: Minimum required version of MariaDB Connector/C is 3.1.3
    #error Minimum required version of MariaDB Connector/C is 3.1.3
     ^
    ./include/mariadb_python.h:244:30: error: field has incomplete type 'enum enum_indicator_type'
        enum enum_indicator_type indicator;
                                 ^
    ./include/mariadb_python.h:244:10: note: forward declaration of 'enum enum_indicator_type'
        enum enum_indicator_type indicator;
             ^
    ./include/mariadb_python.h:297:5: error: unknown type name 'ps_field_fetch_func'
        ps_field_fetch_func func;
        ^
    mariadb/mariadb.c:273:45: error: use of undeclared identifier 'STMT_INDICATOR_NULL'
                           MrdbIndicator_Object(STMT_INDICATOR_NULL));
                                                ^
    mariadb/mariadb.c:275:45: error: use of undeclared identifier 'STMT_INDICATOR_DEFAULT'
                           MrdbIndicator_Object(STMT_INDICATOR_DEFAULT));
                                                ^
    mariadb/mariadb.c:277:45: error: use of undeclared identifier 'STMT_INDICATOR_IGNORE'
                           MrdbIndicator_Object(STMT_INDICATOR_IGNORE));
                                                ^
    mariadb/mariadb.c:279:45: error: use of undeclared identifier 'STMT_INDICATOR_IGNORE_ROW'
                           MrdbIndicator_Object(STMT_INDICATOR_IGNORE_ROW));
                                                ^
    7 errors generated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/.../bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/yz/_pkhkb0x2xb233lq1n0v193r0000gp/T/pip-install-yeefaepy/mariadb/setup.py'"'"'; __file__='"'"'/private/var/folders/yz/_pkhkb0x2xb233lq1n0v193r0000gp/T/pip-install-yeefaepy/mariadb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/yz/_pkhkb0x2xb233lq1n0v193r0000gp/T/pip-record-ock6ntv0/install-record.txt --single-version-externally-managed --compile --install-headers /Users/.../include/site/python3.7/mariadb Check the logs for full command output.

我尝试过的:

  1. 新的虚拟环境(同样的问题)
  2. 不同的Python版本(相同的问题)
  3. brew install mariadb-connector-c
    mariadb-connector-c 3.3.1 is already installed and up-to-date
  4. brew install libmariadb-dev
    &
    brew install libmariadb3
    (
    No available formula with the name "libmariadb-dev"
    &
    No available formula with the name "libmariadb3"
    )
  5. brew install mariadb
    :安装但未解决问题
  6. 安装不同但仍然相对较新的版本
    mariadb
    :可以做到,但不能解决问题
  7. 取消链接
    mariadb
    并链接
    mariadb-connector-c
    :可以做到,但不能解决问题

我可能已经在兔子洞的某个地方尝试了更多的事情。欢迎任何建议。谢谢。

python mariadb homebrew mariadb-connector-c
2个回答
0
投票

如果你的 XCode 命令行已经过时,无论你是否重新链接 mariadb Connector-c 都没有关系。我无法让它工作: python 3.7、3.8、3.9 或最新的 3.10 版本。 [仅供记录,我使用 pyenv 在我的安装中支持多个 python 版本]

前往 AppStore 并在 XCode 上进行升级解决了该问题。之后就安装成功了:

pip install mariadb

进入上述所有 python 版本,完全没有问题。 有趣的是,我在 MariaDB 文档/要求中找不到任何建议。究竟是什么阻止了 pip 安装,我仍然不知道。

希望这能帮助人们避免一些头痛。


0
投票

我正在安装连接器

brew install mariadb-connector-c

解决这个问题

© www.soinside.com 2019 - 2024. All rights reserved.