简体   繁体   中英

py2exe executable generates log file error

Py2exe builds the executable without exceptions. When I run the executable, a log file is generated with the following:

    Traceback (most recent call last):
       File "ecm2es_gui.py", line 10, in <module>
       File "weblogin.pyo", line 4, in <module>
       File "mechanize\__init__.pyo", line 122, in <module>
       File "mechanize\_mechanize.pyo", line 14, in <module>
       File "mechanize\_html.pyo", line 19, in <module>
       File "mechanize\_form.pyo", line 64, in <module>
    ImportError: No module named inspect

When I run the program from Python Shell, Eclipse, or Geany I get no errors and it runs OK.

I thought my problem was with the installation of Mechanize or the eggs but now I don't think this is the problem.

Any ideas? TIA - Brad

UPDATE... this is my setup.py file:

    from distutils.core import setup
    import py2exe

    import sys; sys.argv.append('py2exe')

    includes = []
    excludes = ['_ssl', 'pdb', 'unittest', 'inspect',
                'pyreadline', 'difflib', 'doctest', 'locale',
                'optparse', 'pickle', 'calendar', '_gtkagg', 
                '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
                'pywin.debugger.dbgcon', 'pywin.dialogs']
    packages = []
    dll_excludes = []

    setup(
        options = {"py2exe": {"compressed": 1,
                              "optimize": 2,
                              "bundle_files": 3,
                              "includes": includes,
                              "excludes": excludes,
                              "packages": packages,
                              "dll_excludes": dll_excludes,
                              "dist_dir": "dist",
                              "xref": False,
                              "skip_archive": False,
                              "ascii": False,
                              "custom_boot_script": '',
                             }
                  },
    #    zipfile = None,
        name='EnerSave Uploader',
        version='0.5',
        description='Upload ECM-1240 Data to EnerSave',
        author='Brad Norman',
        windows=[{"script":"ecm2es_gui.py", 
                  "icon_resources": [(1, "favicon.ico")]}
                ]
        )

The error is

ImportError: No module named inspect

And in your setup script you have inspect in the list of excludes. Remove it from the excludes, and py2exe will package it with your executable so mechanize can use it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM