开发者

When using py2exe, PyQt application cannot load SQlite database

开发者 https://www.devze.com 2022-12-08 08:26 出处:网络
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 supp

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.


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',))],
    ...,
)


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消