问题
should I include modules that I have used in my .py like os
module in code below or its done automatically?and what about exclude?I have used pyqt4
in my .py is it necessary to add its name in this setup.py
file?
import sys
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup( name = "my-app",
version = "0.9.0",
description = "Copyright 2013",
options = {"build_exe": build_exe_options},
executables = [Executable("my_module.py", base=base)])
回答1:
As the comment says, dependencies are automatically detected, but you sometimes need to fine tune them manually. os and tkinter are just there as examples, you probably don't need them for your project. Generally, anything you've import
ed can be detected, but if you load plugin libraries some other way, it won't find them, so you need to specify them.
Try freezing it, and see if it fails because anything is missing, then go back and add that to packages
.
来源:https://stackoverflow.com/questions/20096977/cx-freeze-include-modules-automatically