Home > Enterprise >  Error trying to install mariadb package using pip3
Error trying to install mariadb package using pip3

Time:07-28

I am trying to install mariadb usin pip3 on a python 3.8 environment on a Ubuntu 2004 server.

I did download the mariadb-connector-c (version 3.31) and copied the files to their destinations.

I also installed python2-dev and its dependencies on the systems.

The error I do receive when I launch "pip3 install mariadb" is:

Collecting mariadb
  Using cached mariadb-1.1.3.tar.gz (80 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: mariadb
  Building wheel for mariadb (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [47 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-38
      creating build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/__init__.py -> build/lib.linux-x86_64-cpython-38/mariadb
      creating build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/__init__.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/CURSOR.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/STATUS.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/TPC_STATE.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/INFO.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/field.py -> build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/connections.py -> build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/connectionpool.py -> build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/dbapi20.py -> build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/cursors.py -> build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/release_info.py -> build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/constants/ERR.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/FIELD_FLAG.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/INDICATOR.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      running build_ext
      building 'mariadb._mariadb' extension
      creating build/temp.linux-x86_64-cpython-38
      creating build/temp.linux-x86_64-cpython-38/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=3 -DPY_MARIADB_PRE_RELEASE_SEGMENT=\"\" -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/var/sas/scrap_venv/include -I/usr/include/python3.8 -c mariadb/mariadb.c -o build/temp.linux-x86_64-cpython-38/mariadb/mariadb.o -DDEFAULT_PLUGINS_SUBDIR=\"/usr/lib/mariadb/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 -fPIC -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=1 -DPY_MARIADB_PATCH_VERSION=3 -DPY_MARIADB_PRE_RELEASE_SEGMENT=\"\" -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/var/sas/scrap_venv/include -I/usr/include/python3.8 -c mariadb/mariadb_codecs.c -o build/temp.linux-x86_64-cpython-38/mariadb/mariadb_codecs.o -DDEFAULT_PLUGINS_SUBDIR=\"/usr/lib/mariadb/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 -fPIC -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=1 -DPY_MARIADB_PATCH_VERSION=3 -DPY_MARIADB_PRE_RELEASE_SEGMENT=\"\" -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/var/sas/scrap_venv/include -I/usr/include/python3.8 -c mariadb/mariadb_connection.c -o build/temp.linux-x86_64-cpython-38/mariadb/mariadb_connection.o -DDEFAULT_PLUGINS_SUBDIR=\"/usr/lib/mariadb/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 -fPIC -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=1 -DPY_MARIADB_PATCH_VERSION=3 -DPY_MARIADB_PRE_RELEASE_SEGMENT=\"\" -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/var/sas/scrap_venv/include -I/usr/include/python3.8 -c mariadb/mariadb_cursor.c -o build/temp.linux-x86_64-cpython-38/mariadb/mariadb_cursor.o -DDEFAULT_PLUGINS_SUBDIR=\"/usr/lib/mariadb/plugin\"
      mariadb/mariadb_cursor.c: In function ‘MrdbCursor_execute_binary’:
      mariadb/mariadb_cursor.c:1094:48: error: ‘const struct st_mariadb_methods’ has no member named ‘db_execute_generate_request’
       1094 |     if (!(buf= self->connection->mysql->methods->db_execute_generate_request(self->stmt, &buflen, 1)))
            |                                                ^~
      mariadb/mariadb_cursor.c:1058:20: warning: variable ‘buf’ set but not used [-Wunused-but-set-variable]
       1058 |     unsigned char *buf= NULL;
            |                    ^~~
      mariadb/mariadb_cursor.c: In function ‘MrdbCursor_execute_bulk’:
      mariadb/mariadb_cursor.c:1205:48: error: ‘const struct st_mariadb_methods’ has no member named ‘db_execute_generate_request’
       1205 |     if (!(buf= self->connection->mysql->methods->db_execute_generate_request(self->stmt, &buflen, 1)))
            |                                                ^~
      mariadb/mariadb_cursor.c:1169:20: warning: variable ‘buf’ set but not used [-Wunused-but-set-variable]
       1169 |     unsigned char *buf= NULL;
            |                    ^~~
      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
  Running setup.py clean for mariadb
Failed to build mariadb
Installing collected packages: mariadb
  Running setup.py install for mariadb ... error
  error: subprocess-exited-with-error

  × Running setup.py install for mariadb did not run successfully.
  │ exit code: 1
  ╰─> [49 lines of output]
      running install
      /var/sas/scrap_venv/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-38
      creating build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/__init__.py -> build/lib.linux-x86_64-cpython-38/mariadb
      creating build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/__init__.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/CURSOR.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/STATUS.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/TPC_STATE.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/INFO.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/field.py -> build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/connections.py -> build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/connectionpool.py -> build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/dbapi20.py -> build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/cursors.py -> build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/release_info.py -> build/lib.linux-x86_64-cpython-38/mariadb
      copying mariadb/constants/ERR.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/FIELD_FLAG.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      copying mariadb/constants/INDICATOR.py -> build/lib.linux-x86_64-cpython-38/mariadb/constants
      running build_ext
      building 'mariadb._mariadb' extension
      creating build/temp.linux-x86_64-cpython-38
      creating build/temp.linux-x86_64-cpython-38/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=3 -DPY_MARIADB_PRE_RELEASE_SEGMENT=\"\" -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/var/sas/scrap_venv/include -I/usr/include/python3.8 -c mariadb/mariadb.c -o build/temp.linux-x86_64-cpython-38/mariadb/mariadb.o -DDEFAULT_PLUGINS_SUBDIR=\"/usr/lib/mariadb/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 -fPIC -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=1 -DPY_MARIADB_PATCH_VERSION=3 -DPY_MARIADB_PRE_RELEASE_SEGMENT=\"\" -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/var/sas/scrap_venv/include -I/usr/include/python3.8 -c mariadb/mariadb_codecs.c -o build/temp.linux-x86_64-cpython-38/mariadb/mariadb_codecs.o -DDEFAULT_PLUGINS_SUBDIR=\"/usr/lib/mariadb/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 -fPIC -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=1 -DPY_MARIADB_PATCH_VERSION=3 -DPY_MARIADB_PRE_RELEASE_SEGMENT=\"\" -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/var/sas/scrap_venv/include -I/usr/include/python3.8 -c mariadb/mariadb_connection.c -o build/temp.linux-x86_64-cpython-38/mariadb/mariadb_connection.o -DDEFAULT_PLUGINS_SUBDIR=\"/usr/lib/mariadb/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 -fPIC -DPY_MARIADB_MAJOR_VERSION=1 -DPY_MARIADB_MINOR_VERSION=1 -DPY_MARIADB_PATCH_VERSION=3 -DPY_MARIADB_PRE_RELEASE_SEGMENT=\"\" -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I./include -I/var/sas/scrap_venv/include -I/usr/include/python3.8 -c mariadb/mariadb_cursor.c -o build/temp.linux-x86_64-cpython-38/mariadb/mariadb_cursor.o -DDEFAULT_PLUGINS_SUBDIR=\"/usr/lib/mariadb/plugin\"
      mariadb/mariadb_cursor.c: In function ‘MrdbCursor_execute_binary’:
      mariadb/mariadb_cursor.c:1094:48: error: ‘const struct st_mariadb_methods’ has no member named ‘db_execute_generate_request’
       1094 |     if (!(buf= self->connection->mysql->methods->db_execute_generate_request(self->stmt, &buflen, 1)))
            |                                                ^~
      mariadb/mariadb_cursor.c:1058:20: warning: variable ‘buf’ set but not used [-Wunused-but-set-variable]
       1058 |     unsigned char *buf= NULL;
            |                    ^~~
      mariadb/mariadb_cursor.c: In function ‘MrdbCursor_execute_bulk’:
      mariadb/mariadb_cursor.c:1205:48: error: ‘const struct st_mariadb_methods’ has no member named ‘db_execute_generate_request’
       1205 |     if (!(buf= self->connection->mysql->methods->db_execute_generate_request(self->stmt, &buflen, 1)))
            |                                                ^~
      mariadb/mariadb_cursor.c:1169:20: warning: variable ‘buf’ set but not used [-Wunused-but-set-variable]
       1169 |     unsigned char *buf= NULL;
            |                    ^~~
      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: legacy-install-failure

× Encountered error while trying to install package.
╰─> mariadb

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Any hint on how to install it?

Best, apnow

CodePudding user response:

Since setup.py doesn't claim about missing Connector/C version (required is C/C 3.2.4 for Connector/Python 1.1.x) it looks like that mariadb_config (which will be used to check the installed version) was found, but somewhere is another mysql.h include file (either from an older MariaDB Connector/C, MariaDB Server or MySQL installation) which will be used instead.

I would suggest to check the include paths for the build:

export CFLAGS="-v -E"
pip3 install mariadb >& output.txt

Then open output.txt in your favourite editor and search for "search starts here" where you can see the include paths for the build:

#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/mariadb
 /usr/local/include/mariadb/mysql
 ./include
 /usr/local/include/python3.10
 /usr/lib/gcc/x86_64-linux-gnu/10/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include

CodePudding user response:

@phd: I did uninstall python2-dev (yes, it was not needed)

@Georg Ritcher: I did remove the libmysqlclient installed previously for a MySQL connection. I also executed the commands you mentioned above and somehow, it worked!

I did receive this output:

Collecting mariadb
  Using cached MariaDB-1.1.3.tar.gz (80 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Building wheels for collected packages: mariadb
  Building wheel for mariadb (setup.py): started
  Building wheel for mariadb (setup.py): finished with status 'done'
  Created wheel for mariadb: filename=mariadb-1.1.3-cp38-cp38-linux_x86_64.whl size=46386 sha256=fb15f61a17c9ff2ccc924c8c530bcf0817573498b9c4942feccbde7d7eaacceb
  Stored in directory: /home/apnow/.cache/pip/wheels/cd/97/c7/77b7fa75c136ad230c5352abc75f29ae024da818057add5e7d
Successfully built mariadb
Installing collected packages: mariadb
Successfully installed mariadb-1.1.3

I can see mariadb 1.1.3 installed on my environment now. Maybe the libmysqlclient was affecting the installation of it?

Thanks for all support!

All best, apnow

CodePudding user response:

well, seems it´s not working completely.

I tried to import mariadb library directly on my terminal using:

(scrap_venv) apnow@web:/var/sas/scrap$ python
Python 3.8.10 (default, Jun 22 2022, 20:18:18)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mariadb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/sas/scrap_venv/lib/python3.8/site-packages/mariadb/__init__.py", line 6, in <module>
    from ._mariadb import (
ModuleNotFoundError: No module named 'mariadb._mariadb'
>>>

But it shows that the module is not found

If I launch pip3 show mariadb

I get this output:

Name: mariadb
Version: 1.1.3
Summary: Python MariaDB extension
Home-page: https://www.github.com/mariadb-corporation/mariadb-connector-python
Author: Georg Richter
Author-email:
License: LGPL 2.1
Location: /var/sas/scrap_venv/lib/python3.8/site-packages
Requires:
Required-by:

Any idea?

All best, apnow

  • Related