简体   繁体   English

Pip 安装 mariadb mac

[英]Pip install mariadb mac

I'm wanting to connect to a MariaDB database for a web app via Python but can't seem to install the mariadb package. I'm wanting to connect to a MariaDB database for a web app via Python but can't seem to install the mariadb package. I am running Mac with Python 3.7.9.我正在使用 Python 3.7.9 运行 Mac。 Here is what I get when I try to run pip install mariadb is:这是我尝试运行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.

What I've tried:我试过的:

  1. New virtual environment (same issue)新的虚拟环境(同样的问题)
  2. Different Python version (same issue)不同的 Python 版本(相同问题)
  3. brew install mariadb-connector-c ( mariadb-connector-c 3.3.1 is already installed and up-to-date ) 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" ) brew install No available formula with the name "libmariadb3" brew install libmariadb-dev & brew install libmariadb3 No available formula with the name "libmariadb-dev"
  5. brew install mariadb : installs but doesn't fix issue brew install mariadb :安装但不解决问题
  6. Installing different but still relatively recent versions of mariadb : can do it but doesn't fix issue安装不同但仍然相对较新的mariadb版本:可以,但不能解决问题
  7. Unlinking mariadb and linking mariadb-connector-c : can do it but doesn't fix issue取消链接mariadb并链接mariadb-connector-c :可以做到但不能解决问题

I've probably tried a few more things somewhere along the rabbit hole.我可能在兔子洞的某个地方尝试了更多的东西。 Any suggestions welcome.欢迎任何建议。 Thanks.谢谢。

If your XCode Command Line is out of date, it doesn't matter if you relink the mariadb connector-c or not.如果您的 XCode 命令行已过期,则重新链接 mariadb 连接器-c 与否无关紧要。 I couldn't make it work with: python 3.7, 3.8, 3.9 or the latest 3.10 versions.我无法使用:python 3.7、3.8、3.9 或最新的 3.10 版本。 [just for the record, I use pyenv to support several python versions on my installation] [仅作记录,我在我的安装中使用 pyenv 支持几个 python 版本]

Going to AppStore and doing upgrade on XCode fixed the issue.前往 AppStore 并在 XCode 上进行升级修复了该问题。 After that, successfully installed:之后,成功安装:

pip install mariadb

into all of the above python versions with no issues at all.进入所有上述 python 版本,完全没有问题。 Interesting that I couldn't find any recommendation in MariaDB documentaion/requirements.有趣的是,我在 MariaDB 文档/要求中找不到任何建议。 What exactly prevented the pip installation, I still don't know.究竟是什么阻止了 pip 的安装,我仍然不知道。

Hopefully this will help someone to avoid some headache.希望这将帮助某人避免一些头痛。

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

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