Python Cx_freeze Packaging Tool handling problem ideas and solutions

Source: Internet
Author: User
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.