2013-11-20 103 views
0

應該包含我在.py中使用的模塊,如os模塊在下面的代碼中,或者它自動完成嗎?以及排除是什麼?我在我的.py中使用了pyqt4是否需要添加它這個setup.py文件中的名字?Cx_Freeze - 自動包含模塊

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)]) 

回答

2

正如評論所說,依賴性會自動檢測到,但有時您需要手動對它們進行微調。 os和tkinter只是作爲例子,你可能不需要它們用於你的項目。一般來說,你可以檢測到任何東西,但是如果你用其他方式加載插件庫,它不會找到它們,所以你需要指定它們。

試着凍結它,看它是否失敗,因爲缺少任何東西,然後返回並將其添加到packages