简体   繁体   中英

MariaDB Connector/Python installation issue on Ubuntu 20.04 (

I ran into an issue installing mariadb connector for python on Ubuntu 20.04. I did installed mariadb server and connector for C as they say in the docs:

sudo apt-get update        
sudo apt-get install mariadb-server
sudo apt-get install libmariadb3
sudo apt-get install libmariadb-dev
   

Also installed:

sudo apt-get install libmariadbclient-dev

Then:

$ pip3 install mariadb
Collecting mariadb   Using cached mariadb-1.0.3.tar.gz (66 kB) Building wheels for collected packages: mariadb   Building wheel for mariadb (setup.py) ... error   ERROR: Command errored out with exit status 1:    command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-01wak5oz/mariadb/setup.py'"'"';
__file__='"'"'/tmp/pip-install-01wak5oz/mariadb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-oazbv39u
       cwd: /tmp/pip-install-01wak5oz/mariadb/   Complete output (40 lines):   running bdist_wheel   running build   running build_py   creating build   creating build/lib.linux-x86_64-3.8   creating build/lib.linux-x86_64-3.8/mariadb   copying mariadb/__init__.py -> build/lib.linux-x86_64-3.8/mariadb   creating build/lib.linux-x86_64-3.8/mariadb/constants   copying mariadb/constants/__init__.py -> build/lib.linux-x86_64-3.8/mariadb/constants   copying mariadb/constants/CLIENT.py -> build/lib.linux-x86_64-3.8/mariadb/constants   copying mariadb/constants/INDICATOR.py -> build/lib.linux-x86_64-3.8/mariadb/constants   copying mariadb/constants/CURSOR.py -> build/lib.linux-x86_64-3.8/mariadb/constants   copying mariadb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.8/mariadb/constants   running build_ext   building 'mariadb._mariadb' extension   creating build/temp.linux-x86_64-3.8   creating build/temp.linux-x86_64-3.8/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 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=0 -DPY_MARIADB_PATCH_VERSION=3 -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/usr/include/python3.8 -c mariadb/mariadb.c -o build/temp.linux-x86_64-3.8/mariadb/mariadb.o
-DDEFAULT_PLUGINS_SUBDIR="/usr/lib/x86_64-linux-gnu/mariadb19/plugin"   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 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=0 -DPY_MARIADB_PATCH_VERSION=3 -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/usr/include/python3.8 -c mariadb/mariadb_connection.c -o build/temp.linux-x86_64-3.8/mariadb/mariadb_connection.o
-DDEFAULT_PLUGINS_SUBDIR="/usr/lib/x86_64-linux-gnu/mariadb19/plugin"   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 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=0 -DPY_MARIADB_PATCH_VERSION=3 -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/usr/include/python3.8 -c mariadb/mariadb_exception.c -o build/temp.linux-x86_64-3.8/mariadb/mariadb_exception.o
-DDEFAULT_PLUGINS_SUBDIR="/usr/lib/x86_64-linux-gnu/mariadb19/plugin"   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 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=0 -DPY_MARIADB_PATCH_VERSION=3 -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/usr/include/python3.8 -c mariadb/mariadb_cursor.c -o build/temp.linux-x86_64-3.8/mariadb/mariadb_cursor.o
-DDEFAULT_PLUGINS_SUBDIR="/usr/lib/x86_64-linux-gnu/mariadb19/plugin"   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 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=0 -DPY_MARIADB_PATCH_VERSION=3 -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/usr/include/python3.8 -c mariadb/mariadb_codecs.c -o build/temp.linux-x86_64-3.8/mariadb/mariadb_codecs.o
-DDEFAULT_PLUGINS_SUBDIR="/usr/lib/x86_64-linux-gnu/mariadb19/plugin"   mariadb/mariadb_codecs.c: In function ‘mariadb_extended_field_type’:   mariadb/mariadb_codecs.c:64:5: error: unknown type name ‘MARIADB_CONST_STRING’
     64 |     MARIADB_CONST_STRING str;
        |     ^~~~~~~~~~~~~~~~~~~~   mariadb/mariadb_codecs.c:66:10: warning: implicit declaration of function ‘mariadb_field_attr’ [-Wimplicit-function-declaration]
     66 |     if (!mariadb_field_attr(&str, field, MARIADB_FIELD_ATTR_FORMAT_NAME))
        |          ^~~~~~~~~~~~~~~~~~   mariadb/mariadb_codecs.c:66:42: error: ‘MARIADB_FIELD_ATTR_FORMAT_NAME’ undeclared (first use in this function)
     66 |     if (!mariadb_field_attr(&str, field, MARIADB_FIELD_ATTR_FORMAT_NAME))
        |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   mariadb/mariadb_codecs.c:66:42: note: each undeclared identifier is reported only once for each function it appears in   mariadb/mariadb_codecs.c:68:14: error: request for member ‘length’ in something not a structure or union
     68 |       if (str.length == 4 && !strncmp(str.str, "json", 4))
        |              ^   mariadb/mariadb_codecs.c:68:42: error: request for member ‘str’ in something not a structure or union
     68 |       if (str.length == 4 && !strncmp(str.str, "json", 4))
        |                                          ^   error: command 'x86_64-linux-gnu-gcc' failed with exit status 1  
----------------------------------------   ERROR: Failed building wheel for mariadb   Running setup.py clean for mariadb Failed to build mariadb

It seems that issue comes from:

  mariadb/mariadb_codecs.c: In function ‘mariadb_extended_field_type’:
  mariadb/mariadb_codecs.c:64:5: error: unknown type name ‘MARIADB_CONST_STRING’

But I'm not good in C and unable to investigate this right away. Tried googling, but no results for issues caused by MARIADB_CONST_STRING type.

It is my first time installing mariadb connector for python on ubuntu. Did anyone seen this error before? How should I proceed? Appreciate your advise.

I went through more docs: https://mariadb.com/kb/en/installing-mariadb-deb-files/

What helped was:

curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

Then again:

$ sudo apt-get update
$ sudo apt-get install libmariadb3

Now lets try to install Python mariadb lib:

$ pip3 install mariadb
Collecting mariadb
  Using cached mariadb-1.0.3.tar.gz (66 kB)
Building wheels for collected packages: mariadb
  Building wheel for mariadb (setup.py) ... done
  Created wheel for mariadb: filename=mariadb-1.0.3-cp38-cp38-linux_x86_64.whl size=233300 sha256=607a788847d8d023a8921f7fc8fa9a5450b0e7f0625416de86d26cedfe202e73
  Stored in directory: /home/sergey/.cache/pip/wheels/c5/56/1d/ade90f725a5f6a15b505bebc461ebfc573223e9836c5bf5603
Successfully built mariadb
Installing collected packages: mariadb
Successfully installed mariadb-1.0.3

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