无法安装python的mariadb连接器

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

我使用的是 arch linux 系统。
我正在使用使用以下方法创建的虚拟环境:

python -m venv .venv

我想使用 python 连接到 mariadb。
首先使用“mysql-connector-python”,但它有一些问题。
    raise get_mysql_exception(
mysql.connector.errors.DatabaseError: 1273 (HY000): Unknown collation: 'utf8mb4_0900_ai_ci'

然后我尝试使用以下方式下载 mariadb 连接器:

source .venv/bin/activate
pip3 install mariadb

我收到此错误,并且似乎找不到任何出路

Collecting mariadb==1.0.11
  Downloading mariadb-1.0.11.zip (85 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: mariadb
  Building wheel for mariadb (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for mariadb (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [36 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build/lib.linux-x86_64-cpython-312/mariadb
      copying mariadb/__init__.py -> build/lib.linux-x86_64-cpython-312/mariadb
      copying mariadb/__init__.py -> build/lib.linux-x86_64-cpython-312/mariadb
      creating build/lib.linux-x86_64-cpython-312/mariadb/constants
      copying mariadb/constants/__init__.py -> build/lib.linux-x86_64-cpython-312/mariadb/constants
      copying mariadb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-312/mariadb/constants
      copying mariadb/constants/INDICATOR.py -> build/lib.linux-x86_64-cpython-312/mariadb/constants
      copying mariadb/constants/CURSOR.py -> build/lib.linux-x86_64-cpython-312/mariadb/constants
      copying mariadb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-312/mariadb/constants
      running build_ext
      building 'mariadb._mariadb' extension
      creating build/temp.linux-x86_64-cpython-312/mariadb
      gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -ffat-lto-objects -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -fPIC -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=0 -DPY_MARIADB_PATCH_VERSION=11 -I/usr/include/mysql -I/usr/include/mysql/mysql -I./include -I/home/anand_maurya/Documents/SchoolProject/.venv/include -I/usr/include/python3.12 -c mariadb/mariadb.c -o build/temp.linux-x86_64-cpython-312/mariadb/mariadb.o -DDEFAULT_PLUGINS_SUBDIR=\"/usr/lib/mysql/plugin\"
      mariadb/mariadb.c: In function ‘PyInit__mariadb’:
      mariadb/mariadb.c:155:35: error: lvalue required as left operand of assignment
        155 |     Py_TYPE(&MrdbConnection_Type) = &PyType_Type;
            |                                   ^
      mariadb/mariadb.c:168:31: error: lvalue required as left operand of assignment
        168 |     Py_TYPE(&MrdbCursor_Type) = &PyType_Type;
            |                               ^
      mariadb/mariadb.c:174:29: error: lvalue required as left operand of assignment
        174 |     Py_TYPE(&MrdbPool_Type) = &PyType_Type;
            |                             ^
      mariadb/mariadb.c:180:34: error: lvalue required as left operand of assignment
        180 |     Py_TYPE(&MrdbIndicator_Type) = &PyType_Type;
            |                                  ^
      mariadb/mariadb.c:186:38: error: lvalue required as left operand of assignment
        186 |     Py_TYPE(&Mariadb_Fieldinfo_Type) = &PyType_Type;
            |                                      ^
      mariadb/mariadb.c:192:38: error: lvalue required as left operand of assignment
        192 |     Py_TYPE(&Mariadb_DBAPIType_Type) = &PyType_Type;
            |                                      ^
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for mariadb
Failed to build mariadb
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (mariadb)

如有任何反馈,我们将不胜感激。

python pip mariadb
1个回答
0
投票

MariaDB Connector/Python 1.0.x 分支不再维护 - 使用 1.1.x 代替。

如果您想使用旧的 1.0.11 版本,您还需要使用旧的 Python 版本。 MariaDB Connector/Python 1.0.11 支持的 Python 版本在 setup.py 中定义:

      'Programming Language :: Python :: 3.6',
      'Programming Language :: Python :: 3.7',
      'Programming Language :: Python :: 3.8',
      'Programming Language :: Python :: 3.9',
      'Programming Language :: Python :: 3.10',
© www.soinside.com 2019 - 2024. All rights reserved.