I got a problem with installing mariaDB on my linux/ubuntu server. I try to install it but ist got an error(you can see the complete console log under) and I have no idea how to fix it and I don#t found any solution for this problem online.
root@vmd92300:~# pip3 install mariadb==1.1.6
Collecting mariadb==1.1.6
Using cached mariadb-1.1.6.tar.gz (83 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting packaging (from mariadb==1.1.6)
Using cached packaging-23.1-py3-none-any.whl (48 kB)
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
creating build/lib.linux-x86_64-cpython-310
creating build/lib.linux-x86_64-cpython-310/mariadb
copying mariadb/__init__.py -> build/lib.linux-x86_64-cpython-310/mariadb
copying mariadb/connectionpool.py -> build/lib.linux-x86_64-cpython-310/mariadb
copying mariadb/connections.py -> build/lib.linux-x86_64-cpython-310/mariadb
creating build/lib.linux-x86_64-cpython-310/mariadb/constants
copying mariadb/constants/__init__.py -> build/lib.linux-x86_64-cpython-310/mariadb/constants
copying mariadb/constants/CAPABILITY.py -> build/lib.linux-x86_64-cpython-310/mariadb/constants
copying mariadb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-310/mariadb/constants
copying mariadb/constants/CURSOR.py -> build/lib.linux-x86_64-cpython-310/mariadb/constants
copying mariadb/constants/ERR.py -> build/lib.linux-x86_64-cpython-310/mariadb/constants
copying mariadb/constants/FIELD_FLAG.py -> build/lib.linux-x86_64-cpython-310/mariadb/constants
copying mariadb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-310/mariadb/constants
copying mariadb/constants/INDICATOR.py -> build/lib.linux-x86_64-cpython-310/mariadb/constants
copying mariadb/constants/INFO.py -> build/lib.linux-x86_64-cpython-310/mariadb/constants
copying mariadb/constants/STATUS.py -> build/lib.linux-x86_64-cpython-310/mariadb/constants
copying mariadb/constants/TPC_STATE.py -> build/lib.linux-x86_64-cpython-310/mariadb/constants
copying mariadb/cursors.py -> build/lib.linux-x86_64-cpython-310/mariadb
copying mariadb/dbapi20.py -> build/lib.linux-x86_64-cpython-310/mariadb
copying mariadb/field.py -> build/lib.linux-x86_64-cpython-310/mariadb
copying mariadb/release_info.py -> build/lib.linux-x86_64-cpython-310/mariadb
running build_ext
building 'mariadb._mariadb' extension
creating build/temp.linux-x86_64-cpython-310
creating build/temp.linux-x86_64-cpython-310/mariadb
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=1 -DPY_MARIADB_PATCH_VERSION=6 -DPY_MARIADB_PRE_RELEASE_SEGMENT=\"None\" -DPY_MARIADB_PRE_RELEASE_NR=\"0\" -DPY_MARIADB_POST_RELEASE_SEGMENT=\"None\" -DPY_MARIADB_POST_RELEASE_NR=\"0\" -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/usr/include/python3.10 -c mariadb/mariadb.c -o build/temp.linux-x86_64-cpython-310/mariadb/mariadb.o -DDEFAULT_PLUGINS_SUBDIR=\"/usr/lib/mariadb/plugin\"
In file included from mariadb/mariadb.c:21:
./include/mariadb_python.h:21:10: fatal error: Python.h: No such file or directory
21 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-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: Could not build wheels for mariadb, which is required to install pyproject.toml-based projects
The error is:
fatal error: Python.h: No such file or directory
In order to build the mariadb
module you need the Python development libraries and header files. These need to be installed using your system package manager (unless you've built Python from source). On Redhat/Fedora/Centos/etc, that will be:
yum install python3-devel
On Debian/Ubuntu/etc, that will be:
apt install python3-dev
And on anything else, the general idea is the same but the specific commands may be different.
On a fresh Ubuntu 22.04 system, I only had to:
Install python3 and pip:
apt install python3 python3-pip
Install the mariadb development libraries:
apt install libmariadb-dev
After that I was able to successfully install the mariadb
module:
root@af604c437a1e:/# pip3 install mariadb
Collecting mariadb
Downloading mariadb-1.1.6.tar.gz (83 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.7/83.7 KB 3.3 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting packaging
Using cached packaging-23.1-py3-none-any.whl (48 kB)
Building wheels for collected packages: mariadb
Building wheel for mariadb (pyproject.toml) ... done
Created wheel for mariadb: filename=mariadb-1.1.6-cp310-cp310-linux_x86_64.whl size=181894 sha256=269b7cb4d3fea8a4ed665d5fb924df881037107836437da7ab5ca734d82d2ccb
Stored in directory: /root/.cache/pip/wheels/8d/5c/30/26dc67e1971de894e0c55046043b0e20643ba15a662e575b6f
Successfully built mariadb
Installing collected packages: packaging, mariadb
Successfully installed mariadb-1.1.6 packaging-23.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@af604c437a1e:/# python3
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mariadb
>>>