0
我正在使用cx_Freeze
將我的腳本轉換爲可執行文件。我的問題是,cx_Freeze
只執行我的main.py
,而不執行我的main.py
調用的其他.py
文件。我怎樣才能包含我的其他Python文件?python - 在cx_Freeze中包含其他python文件
我是新來的cx_Freeze,所以我希望有人能幫助我。
我正在使用cx_Freeze
將我的腳本轉換爲可執行文件。我的問題是,cx_Freeze
只執行我的main.py
,而不執行我的main.py
調用的其他.py
文件。我怎樣才能包含我的其他Python文件?python - 在cx_Freeze中包含其他python文件
我是新來的cx_Freeze,所以我希望有人能幫助我。
您可以在腳本中使用include_files
參數。只需將其添加到您的設置腳本。例如,在這短短的劇本我做:
from cx_Freeze import setup, Executable
files = {"include_files": ["<Path to Files>/somefile.py", "<Path to file>/someotherfile.py"], "packages": []}
setup(
name = "Name of app",
version = "0.1",
author = "The author",
options = {'build_exe': files},
description = "Enter A Description Here",
executables = [Executable("main.py", base=None)])
你只想把所有你想使用絕對或相對文件路徑files = {"include_files": ["<Path to Files>/somefile.py", "<Path to file>/someotherfile.py"], "packages": []}
參數中包含的文件。
這會將這些文件複製到您的構建文件夾中。
第二種方法是將它們手動複製到build文件夾中,但第一種方法絕對是最好的!