Я использую виртуальную среду, созданную с помощью:
Код: Выделить всё
python -m venv .venv
Сначала использовал «mysql-connector-python», но возникли некоторые проблемы.
Код: Выделить всё
raise get_mysql_exception(
mysql.connector.errors.DatabaseError: 1273 (HY000): Unknown collation: 'utf8mb4_0900_ai_ci'
Код: Выделить всё
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)
Подробнее здесь: https://stackoverflow.com/questions/791 ... -connector