2

I have witten a GUI app using pyqt5 and includes a QtSql database QSQLITE. The app works perfectly. However when I run pyinstaller to a package my app, the app runs until the time where it has to invoke QtSQL DATABASE QSQLITE. This is the error I get

QSqlDatabase: QSQLITE driver not loaded QSqlDatabase: available drivers:

How do I load the driver so that it can be included when I run pyinstaller.

Thank you

2
  • You should post the section of code where the sqlite driver is loaded. Commented Dec 4, 2017 at 23:40
  • @MalloyDelacroix The problem is not related to the code but to Pyinstaller. I actually experiencing the same problem but with QMYSQL driver and using PySide. The application works fine into a python interpreter but this error appears when running the executable created with PyInstaller Commented Dec 7, 2017 at 15:59

1 Answer 1

0

I experienced the same problem with QMYSQL driver using PySide and I found a solution.

You need to manually include the driver into the qt4_plugins/sqldrivers/ bundle directory.
For that, in your spec file add :

a = Analysis(...
    binaries=[('/usr/lib/x86_64-linux-gnu/qt4/plugins/sqldrivers/libqsqlmysql.so', 'qt4_plugins/sqldrivers')],
    ...
)

This will works for QMYSQL driver but you just need to find the name of the SQLITE driver (probably libqsqlsqlite)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the response Loic. I just tried your solution and it seems to work. I also discovered that if I compile pyinstaller in a virtual environment with a fresh install of pyqt5 and python. The drivers are automatically added. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.