Cx Freeze - 如何将多个文件转换为构建文件夹

时间:2017-07-25 22:56:44

标签: python cx-freeze

我创建了一个使用os.startfile()启动另一个python程序的程序。

我希望将其作为两个exe文件,使用subprocess.call()代替在1个构建文件夹中启动第二个,但我找不到如何执行此操作。

我尝试为两者创建一个安装文件,创建2个构建文件夹,然后将1个exe文件复制到另一个构建文件夹中,但得到了这个:

Traceback (most recent call last): 
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 12, 
in <module> __import__(name + "__init__") 
ImportError: No module named 'menu_record__init__'

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

I am quite sure that you cannot use two exe in one build folder because although all the dependencies in the build folder are the same the scripts are different.

You can use get two exe in the same build folder with this script.

import sys
from cx_Freeze import setup, Executable

options = {
'build_exe': {'path': sys.path + ['modules']}
}

executables = [
    Executable('script_1.py'),
    Executable('script_2.py')]

setup(
    name='two exe in one folder',
    version='0.1',
    description='Two exe in a single build folder',
    options=options,
    executables=executables)

Check out this other post I made

Also you can copy the second build folder in the first (you will need to rename it to something else not build) and call subprocess.call() to the second build file exe.

Otherwise I have heard (although I have never tried it) that pyinstaller or py2exe (I am not sure which) can make a single file exe.