[MDEV-13208] Cannot import libmariadbclient.so.18 from python Created: 2017-06-29  Updated: 2019-04-02  Resolved: 2017-09-21

Status: Closed
Project: MariaDB Server
Component/s: Platform Debian
Affects Version/s: 10.1.23
Fix Version/s: 10.1.27

Type: Bug Priority: Major
Reporter: Emilien Mantel Assignee: Sergei Golubchik
Resolution: Fixed Votes: 2
Labels: None
Environment:

Debian Stretch


Issue Links:
Relates
relates to MDEV-11979 Upgrade from Debian's to MariaDB's 10... Closed
relates to MDEV-12889 libmariadb3 no version information av... Closed

 Description   

Hi!

I have some problems with MariaDB 10.1 (from your repositories). I can't use the python MySQLDb lib.

I don't have any problems on Jessie (Debian or MariaDB repo) or Stretch (Debian repo).

root@4cd9031401a8:/home/vagrant# dpkg -l | grep mariadb
ii  libmariadb-dev              2.3.2-2                        amd64        MariaDB Connector/C, development files
ii  libmariadb2:amd64           2.3.2-2                        amd64        MariaDB Connector/C
ii  libmariadbclient18          10.1.23+maria-1~stretch        amd64        MariaDB database client library
ii  mariadb-client-10.1         10.1.23+maria-1~stretch        amd64        MariaDB database client binaries
ii  mariadb-client-core-10.1    10.1.23+maria-1~stretch        amd64        MariaDB database core client binaries
ii  mariadb-common              10.1.23+maria-1~stretch        all          MariaDB database common files (e.g. /etc/mysql/conf.d/mariadb.cnf)
ii  mariadb-server              10.1.23+maria-1~stretch        all          MariaDB database server (metapackage depending on the latest version)
ii  mariadb-server-10.1         10.1.23+maria-1~stretch        amd64        MariaDB database server binaries
ii  mariadb-server-core-10.1    10.1.23+maria-1~stretch        amd64        MariaDB database core server files
 
root@4cd9031401a8:/home/vagrant# apt-cache policy python-mysqldb
python-mysqldb:
  Installed: 1.3.7-1.1
  Candidate: 1.3.7-1.1
  Version table:
 *** 1.3.7-1.1 500
        500 http://deb.debian.org/debian stretch/main amd64 Packages
        100 /var/lib/dpkg/status
 
 
 
root@4cd9031401a8:/home/vagrant# mysql --version
mysql  Ver 15.1 Distrib 10.1.23-MariaDB, for debian-linux-gnu (x86_64) using readline 5.
 
root@4cd9031401a8:/home/vagrant# apt-cache policy mariadb-common
mariadb-common:
  Installed: 10.1.23+maria-1~stretch
  Candidate: 10.1.23+maria-1~stretch
  Version table:
 *** 10.1.23+maria-1~stretch 500
        500 http://ftp.igh.cnrs.fr/pub/mariadb/repo/10.1/debian stretch/main amd64 Packages
        100 /var/lib/dpkg/status
     10.1.23-9+deb9u1 500
        500 http://deb.debian.org/debian stretch/main amd64 Packages
 
 
root@4cd9031401a8:/home/vagrant# lsb_release -av
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 9.0 (stretch)
Release:	9.0
Codename:	stretch
 
 
root@4cd9031401a8:/home/vagrant# python -c "import MySQLdb"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: libmariadbclient.so.18: cannot open shared object file: No such file or directory

We can bypass the problem by importing latest version of the lib with pip.

root@4cd9031401a8:/home/vagrant# python
Python 2.7.13 (default, Jan 19 2017, 14:48:08) 
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> print MySQLdb.__version__
1.3.10

Cheers!

Emilien



 Comments   
Comment by Sergei Golubchik [ 2017-06-29 ]

You're using MySQLdb from stretch, and our 10.1 packages.

Debian renamed the client library to libmariadbclient.so. And MySQLdb was built with that.

Our 10.1 packages still use libmysqlclient, they provide libmysqlclient.so, our 10.2 packages come with MariaDB Connector/C and provide libmariadb.so (with symlinks to libmysqlclient.so).

Now we need to build our packages to be compatible with stretch. This means libmariadbclient.so symlink and libmariadbclient_18 version nodes...

Comment by Niels Hendriks [ 2017-06-30 ]

Hi,

I'm having a similar issue, though not exactly the same.

I'm using Debian 8 with MariaDB 10.2 and I see the following error:

python -c "import MySQLdb"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory

I have the following package installed:

ii  libmysqlclient18               10.2.6+maria~jessie                                               amd64        Virtual package to satisfy external depends

I can see with a strace it is trying to access this file: /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18 - this file does exist, but it is a symlink:

lrwxrwxrwx 1 root root 26 Jun 30 09:45 /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0

However, libmysqlclient_r.so.18.0.0 does not exist, so it is a broken symlink:

file /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18
/usr/lib/x86_64-linux-gnu/libmysqlclient.so.18: broken symbolic link to libmysqlclient_r.so.18.0.0

As far as I can see, there is a libmariadbclient-dev package supplied by the MariaDB 10.2 repo, but this does not include the libmysqlclient libraries, only the libmariadbclient libraries.
There is also a libmysqlclient-dev package but it is supplied by the Debian repo and not the MariaDB repo. This package has MySQL 5.5 dependencies so it cannot be installed together with mariadb.

I have the following python-mysqldb version:

apt-cache policy python-mysqldb
python-mysqldb:
  Installed: 1.2.3-2.1
  Candidate: 1.2.3-2.1
  Version table:
 *** 1.2.3-2.1 0
        500 http://ftp.nl.debian.org/debian/ jessie/main amd64 Packages
        100 /var/lib/dpkg/status

Comment by Sergei Golubchik [ 2017-06-30 ]

nielsh, your issue is different. This one is about 10.1, that does not have libmariadbclient.so.

Yours is about 10.2 that does not have libmysqlclient.so. This looks more like MDEV-12423 and MDEV-12889

Comment by Sergei Golubchik [ 2017-09-19 ]

Added symlinks, but not version nodes. Reopened, sorry

Comment by Otto Kekäläinen [ 2019-04-02 ]

Related to this, in Debian packaging we test on every commit that this Python module compiles and works:

}}
 
# Build a piece of software that was designed bot libmysqlclient-dev using the
# libmariadb-dev-compat layer. Should always end up using libmariadb.so.3 run-time
test build Python-MySQLdb with mariadbclient:
  stage: test quality
  image: debian:sid
  script:
    - cd ${WORKING_DIR} # Don't repeat this step, it's just cd ./debian/output
    - mkdir debug
    - apt-get update
    - apt-get install -y pkg-config ./libmariadb-dev*.deb ./libmariadb3_*.deb ./mariadb-common*.deb
    - pkg-config --cflags --libs mysqlclient # See what MySQLdb builds with
    - apt-get install -y python3-pip
    - pip3 install mysqlclient # Compiles module against libmysqlclient
    - apt-get purge -y libmariadb-dev # Not needed for run-time
    - python3 -c "import MySQLdb; print(MySQLdb.get_client_info())"
 
{{

Upstream mariadb client libs packaging has a bunch of shortcomings which I think most of are now fixed in the Debian version of MariaDB 10.3 (example: https://salsa.debian.org/mariadb-team/mariadb-10.3/commit/a02149c83bdbeab391ab331b34f28b2bf8352728) and I indend to upstream these into 10.4 (current development branch) this week.

Generated at Thu Feb 08 08:03:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.