简体   繁体   中英

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 am running Mac with Python 3.7.9. Here is what I get when I try to run pip install mariadb is:

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)
  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 : installs but doesn't fix issue
  6. Installing different but still relatively recent versions of mariadb : can do it but doesn't fix issue
  7. Unlinking mariadb and linking mariadb-connector-c : can do it but doesn't fix issue

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. I couldn't make it work with: python 3.7, 3.8, 3.9 or the latest 3.10 versions. [just for the record, I use pyenv to support several python versions on my installation]

Going to AppStore and doing upgrade on XCode fixed the issue. After that, successfully installed:

pip install mariadb

into all of the above python versions with no issues at all. Interesting that I couldn't find any recommendation in MariaDB documentaion/requirements. What exactly prevented the pip installation, I still don't know.

Hopefully this will help someone to avoid some headache.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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