I wrote a small program using PyQt4 and used the sqlite database. Everything works normally in my debugging environment. When I use cx_Freeze to package it and run the corresponding exe, the error always prompts "sqlite driver not loaded". It seems that the driver corresponding to sqlite is not found. So Baidu + google found many people with such problems. The reason for this error is very simple, that is, the DLL library is missing. Cx_Freeze has copied sqlite3.dll and qtsql4.dll to the working directory, but the database driver qsqlite4.dll of QT itself does not. So I found a qsqlite4.dll file and checked it directly to the working directory to run it. An error is still reported. So after in-depth research, we found that the so-called database driver belongs to plugins in qt. These plug-ins must be placed under a specific folder in the working directory during packaging and publishing, for example, the database driver should be placed in the "sqldrivers" directory and be in lower case. See the following table:
Base Class |
Directory Name |
Key case sensiti.pdf |
Qaccessiblebridgeplugin |
Accessiblebridge |
Case Sensitive |
Qaccessibleplugin |
Accessible |
Case Sensitive |
Qdecorationplugin |
Decorations |
Case Sensitive |
Qiconengineplugin |
Iconengines |
Case Insensitive |
Qimageioplugin |
Imageformats |
Case Sensitive |
Qinputcontextplugin |
Inputmethods |
Case Sensitive |
Qkbddriverplugin |
Kbddrivers |
Case Sensitive |
Qmousedriverplugin |
Mousedrivers |
Case Sensitive |
Qpictureformatplugin |
Pictureformats |
Case Sensitive |
Qscreendriverplugin |
Gfxdrivers |
Case Sensitive |
Qscriptextensionplugin |
Script |
Case Sensitive |
Qsqldriverplugin |
Sqldrivers |
Case Sensitive |
Qstyleplugin |
Styles |
Case Insensitive |
Qtextcodecplugin |
Codecs |
Case Sensitive |
Main reference: http://www.cuteqt.com/blog? P = 1002 with plug-ins
Http://www.cuteqt.com/blog? P = 1059 continue with the plug-in
Http://doc.qt.nokia.com/4.3/plugins-howto.html how to create QT plugins
Http://doc.qt.nokia.com/4.3/qt-conf.html using QT. conf.