python – PySide + QtSql – cannot load database drivers – Stack Overflow

Source: python – PySide + QtSql – cannot load database drivers – Stack Overflow

Found a solution here on stackoverflow here (relates to PyQt rather than PySide but it works): PyQT can’t find any SQL drivers

In short – put this code before calling addDatabase:

site_pack_path = site.getsitepackages()[1]
QtGui.QApplication.addLibraryPath('{0}\\PySide\\plugins'.format(site_pack_path))

  • this is what the post-install script should do. Maybe there is some bug in post-install script. Could you run the script and send me here the output ? thanks

    – rlacko

    Apr 27, 2014 at 19:26

  • @V.K Any word on why this fix is even needed? It seems like a bug. Has it been reported to PySide, do you know?

    – eric

    Oct 30, 2014 at 13:21

0

If you encounter a similar issue using modern PySide6, here is the full answer: https://stackoverflow.com/a/72169911/211369

One of solutions is to define the QT_PLUGIN_PATH environment variable, so that it contains the “sqldrivers” sub-directory with SQL plugins for Qt platform.

In your example, QT_PLUGIN_PATH=c:/python-3.3.2/Lib/site-packages/PySide/plugins

BTW almost a half of info known to me is is officially published at https://doc.qt.io/qt-6/deployment-plugins.html

Leave a Reply

The maximum upload file size: 500 MB. You can upload: image, audio, video, document, spreadsheet, interactive, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here