The following are the problems and solutions that are encountered during the use of Cx_freeze (Win7)
1. 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:passelse:# If we found the module, ensure it ' s copied to the build Directory.packages.append (dbmodule) options = {' Build_exe ': {' inclu Des ': ' 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 ']
The above for you to share the Python cx_freeze packaging tools to deal with the problem ideas and solutions, I hope to help you.