On the last day before the festival, all the problems encountered during the packaging process are resolved and can be successfully run! Really a good jackpot, hope that the new year all goes well!
The following are the problems and solutions that are encountered during the use of Cx_freeze (Win7)
- Problem Description: Run EXE, start countless main programs, causing the system to be unusable
cause : A multiprocessing package was used in the program
workaround : In the main file if __name__ = = "__main__": After adding Multiprocessing.freeze_support (), be sure to add at the beginning of the
2. Problem Description: After running, prompt in Freeze_support Sys.stdout.flush exception
cause : Use of PYQT as interface, no console
workaround : Before calling Multiprocessing.freeze_support (), redirect stdout and stderr, add: sys.stdout = io. Stringio () and sys.stderr = io. Stringio ()
3. Using the shelve module, debugging under the IDE can be used normally, cannot be used after packaging
cause : Shelve's Open function also loads other database management modules in the run, without knowing what additional packages are needed, so that some of the necessary modules are missing when packaging
Workaround : Modify the packaging script to add the following:
packages = []
For dbmodule in [' Dbhash ', ' gdbm ', ' dbm ', ' dumbdbm ']:
Try
__import__ (Dbmodule)
Except Importerror:
Pass
Else
# If We found the module, ensure it ' s copied to the build directory.
Packages.append (Dbmodule)
Options = {
' Build_exe ': {
' Includes ': ' Atexit ',
"Packages": Packages
}
}
4. Using Inspect.getsourcelines exception oserror:could not get source code
cause : After packaging, all are PYC files, no source code, resulting in dynamic fetch code failure
Workaround: Package The py file containing the required source code into the Library.zip file, and in the ' Build_exe ' parameter, add ' zip_includes ': [' path\\source.py ']
Python Packaging Tools Cx_freeze problem records and solutions