Py2Exe, Sqlite - Not a valid Win 32 Application

2019-09-09 21:31发布

问题:

I have a Python program that I am attempting to package using Py2Exe. I am using Python 3.4. My program uses Sqlachemy and Sqlite3 in order to create and access the database.

When I install the resulting files from Py2Exe I get the dll error:

Sqlite is not a valid Win32 application

I have attempted to go through the various work-arounds listed here, including uninstall python and re-installing all modules to ensure that I have only the 32 bit versions. Any ideas?

My setup.py code is listed below. It uses some of the work arounds listed for sqlite, as well as a number for sqlalchemy

from distutils.core import setup
import py2exe

setup(console = ['notetest.py'], 
    options = {'py2exe' : {'packages' : [
    'reportlab',
    'reportlab.graphics.charts',
    'reportlab.graphics.samples',
    'reportlab.graphics.widgets',
    'reportlab.graphics.barcode',
    'reportlab.graphics',
    'reportlab.lib',
    'reportlab.pdfbase',
    'reportlab.pdfgen',
    'reportlab.platypus',
    'sqlalchemy.dialects.sqlite',
    #'sqlalchemy.databases.sqlite',
    'sqlite3'
    ]}} )

回答1:

Ok, so i'm not sure if this is a truly "valid" work around, but it works and is rather simple.

I downloaded the most recent Sqlite dll from Sqlite. I simply replaced the Py2Exe generated Sqlite dll with this updated file and the program worked perfectly.

I am also using InnoSetup to compile an MSI installer, so one can simply copy the "newer" dll into the pre-compiled directory for inclusion into the MSI installer.

This worked for me. hope it helps others