Under Ubuntu 17.04 I develop a Python 3 application using PyQt5 (which uses Qt5 5.8.0) and mysql (5.7.18). All has been well recently until today, I now get upon launching:

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7

This is what happens if you have not previously done a:

apt-get install libqt5sql5-mysql

but I have done that, and tried uninstalling it and reinstalling it with same result.

Running locate libqsqlmysql shows me:


The first of these is dated Feb 9 2017, I believe it is Qt5 and not PyQt5, it ldds without error, and I do not think is relevant.

The second however is dated Jun 21 2017, so looks like the culprit. If I go: ldd /usr/local/lib/python3.5/dist-packages/PyQt5/Qt/plugins/sqldrivers/libqsqlmysql.so, in the output I note:

libmysqlclient.so.18 => not found
libssl.so.10 => not found
libcrypto.so.10 => not found

Am I right that is the problem? So it's a PyQt5 issue, not a Qt5 one? Can anyone suggest how to remedy? (I do not have an old state to revert to.)


Well, this turned out to be a pip3/PyCharm issue:

  • I has previously done apt-get install python3-pyqt5.
  • The apt-get install libqt5sql5-mysql had previously installed /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so, and all was well.
  • Then PyCharm made me do apt-get install python3-pip (I was lucky I recalled this), and proceeded to do some kind of pip3 install pyqt5 behind the scenes.
  • This had created its own /usr/local/lib/python3.5/dist-packages/PyQt5/Qt/plugins/sqldrivers/libqsqlmysql.so, and as can be seen from the ldd output there had left the area in an incomplete/inconsistent state.
  • pip3 uninstall pyqt5 removed that, and reverted me to an error-free installation.

I had previously managed to avoid any pip3, successfully installing everything via apt-get. This experience has left me not trusting pip3 at all, if it can simply create an erroneous installation without any messages.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.