简体   繁体   English

使用 cx_freeze 从多个 python 脚本制作可执行的 python 程序

[英]using cx_freeze to make an executable python program from multiple python scripts

i started to use cx_freeze to make my project to an executable after failing with pyinstaller, i'm using tkinter to make a GUI and the main.py GUI is working and when the 2nd script GUI in suppose to initialize it only initialize the window, but without the menu or any dependencies from tkinter such as slider bars, labels or entry boxes在使用 pyinstaller 失败后,我开始使用 cx_freeze 将我的项目制作为可执行文件,我正在使用 tkinter 制作 GUI,并且 main.py GUI 正在工作,当假设第二个脚本 GUI 初始化它时,它只初始化 window,但没有菜单或来自 tkinter 的任何依赖项,例如 slider 条、标签或输入框

my setup.py configured this way:我的 setup.py 是这样配置的:

import sys
from cx_Freeze import setup, Executable


includefiles = ['Doctor.xlsx']
includes = []
excludes = []
packages = ['tkinter', 'openpyxl']
build_exe_options = {'includes': includes, 'packages': packages, 'excludes': excludes, 'include_files': includefiles}

base = None
if sys.platform == 'win64':
    base = 'Win64GUI'
elif sys.platform == 'win32':
    base = 'Win32GUI'

exe = Executable(
    script="Main.py",
    target_name="AutoDoctor",
    base = base
)
setup(
    name="AutoDoctor",
    version="1.0",
    description="Program to diagnose blood results and generate a matching treatment.",
    options={'build_exe': build_exe_options},
    executables=[exe],
)

In the project i have multiple scripts: Main.py, Diagnosis.py, Database.py from my understanding the Database.py working well because the Main.py script is using the Database from the Database.py script.在项目中,我有多个脚本: Main.py, Diagnosis.py, Database.py ,据我了解,Database.py 运行良好,因为 Main.py 脚本使用 Database.py 脚本中的数据库。

if you are on windows, you can do this from desktop.如果您使用的是 windows,则可以从桌面执行此操作。 but if you want to be sure.但如果你想确定的话。 go to your directory and do this: go 到您的目录并执行以下操作: 在此处输入图像描述

open the cmd and put this code in. make sure that you have installed what you need打开 cmd 并输入此代码。确保已安装所需的

Turns out that it was my code that had the problem in my code i destroyed the main window and only then initialized the second function window so it just was an order of function problem. Turns out that it was my code that had the problem in my code i destroyed the main window and only then initialized the second function window so it just was an order of function problem.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM