1

My PyQt application works fine when running on Linux, when in my Windows build environment, or frozen on the machine where it was build with py2exe. But after moving the frozen executable and its supporting files to another machine it can't load the database driver.

It worked fine when I had Python2.5 and an earlier version of PyQt and py2exe. But after upgrading my toolchain I get these errors:

  • dbname.open returns false
  • lastError(dbname) is "Driver not loaded"

I have an sqldrivers folder where I put qsqlite4.dll. This was necessary with the previous build environment, but moving or renaming that DLL doesn't change any behavior. I think that's the DLL that Qt can't find, but I haven't been able to tell Qt where to look.

I am currently running these versions:

  • python-2.6.3
  • PyQt-Py2.6-gpl-4.6-1
  • py2exe-0.6.9.win32-py2.6

Profiling in Dependency Walker gives me this error:
LoadLibraryW("\application\sqldrivers\qsqlite4.dll") returned NULL. Error: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem (14001).
When I ask Dependency Walker for details about Qsqlite4.dll it says:
Error: The Side-by-Side configuration information for "\application\sqldrivers\QSQLITE4.DLL" contains errors.

That would explain why the DLL won't load, but I'm still unclear how to fix it. Closer inspection shows that error for most of the DLLs I call. Do I need to include a manifest for each Qt DLL I load?

Thanks in advance.

resplin
  • 436
  • 5
  • 12
  • Update: Followed a tip on #pyqt and made an qt.conf that specified the path to qsqlite4.dll. Then Dependency Walker stopped complaining about that and instead complained about not finding zlib.pyd. I tried to find zlib.pyd on my build box (not there), and tried to get py2exe to include it (it wouldn't). I rolled back to Python 2.5, py2exe 0.6.9 for py2.5, and PyQt 4.4.3 for 2.5. The application appears to load just fine in this configuration, but now I need to excise PyQt4.6-isms from my code. I still need to upgrade eventually, so any suggestions on how to do it will be very appreciated. – resplin Oct 16 '09 at 05:08
  • Update 2: Downgrading isn't an option because of some of the new features I added. So I tried cx-freeze, but I get the same behavior--no database drivers are loaded. I switched back to py2exe, and profiled both a working application (run on the build machine), and a non-working application (run on a different machine). The output seems identical (they both include the zlib.pyd error), so I don't think that's the problem. – resplin Oct 16 '09 at 05:08

3 Answers3

3

DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far ...

The accepted answer doesn't really say what dlls they copied and in what places. I managed to fix it by copying the driver inside the sqldrivers directory relative to where the exe and qt dlls are (I'm using PySide but should work with PyQt4 as well). In setup.py:

setup(
    ...,
    data_files = [('sqldrivers', ('C:\Python27\Lib\site-packages\PySide\plugins\sqldrivers\qsqlite4.dll',))],
    ...,
)
solarc
  • 5,638
  • 2
  • 40
  • 51
2

I solved it!

I had a really clever way to avoid making my users install vcredist--I copied the manifest and the DLLs into two places and all the errors about the MS DLLs went away. That's when I started trying to figure out this SQLite driver error.

I wasn't as smart as I thought. If I install vcredist all the "Driver Not Loaded" and "No SQL drivers found" errors go away. Arg.

resplin
  • 436
  • 5
  • 12
0

Try to re-install SOLite, or verify if you have putted the DLL in the correct place, because i remember that the MySQL DLL have to be in System32 directory to develop something that uses it.

Regards.

Nathan Campos
  • 28,769
  • 59
  • 194
  • 300
  • Thanks for the suggestion. Since SQLite is included in Python now, no installation is necessary. I tried explicitly including the sqlite3.dll in the package and it didn't make a difference. – resplin Oct 16 '09 at 05:11