带有 tkinter xgboost 的 cxfreeze 小部件未显示但没有错误

jp-*_*ech 5 python tkinter widget cx-freeze xgboost

我的程序正在 anaconda spyder 中运行。但是,在冻结它之后,所有使用 tkinter 模块的小部件都可以工作,但带有 xgboost 和 pandas 的小部件除外。没有显示错误,构建工作但按钮不起作用并且没有显示小部件。

我已经尝试在我的 setup.py 文件中导入并包含 xgboost,但所有其他带有 tkinter 的小部件都无法正常工作。仍然没有错误。有没有人遇到或解决过这个问题?

这是最接近的工作。这是我的 setup.py,当其他小部件与 tkinter 一起工作时,而不是与 xgboost 和 pandas 一起工作的小部件。

from cx_Freeze import setup, Executable
import sys
import os

includes = []
include_files = [r"C:/Users/USER/Anaconda3/DLLs/tcl86t.dll",
         r"C:/Users/USER/Anaconda3/DLLs/tk86t.dll",
         r"C:/Users/USER/SAMPLE/xgboost_USE.model",
         r"C:/Users/USER/SAMPLE/P1.ico"]
os.environ['TCL_LIBRARY'] = "C:/Users/USER/Anaconda3/tcl/tcl8.6"
os.environ['TK_LIBRARY'] = "C:/Users/USER/Anaconda3/tcl/tk8.6"
base = 'Win32GUI' if sys.platform == 'win32' else None


setup(name=application_title, version='1.0', description='SAMPLE',
      options={"build_exe": {"includes": includes, "include_files":                 
      include_files}},executables=
      [Executable(r'C:/Users/USER/SAMPLE/sample.py', base=base)])
Run Code Online (Sandbox Code Playgroud)

请帮忙。

小智 0

我对 xgboost 没有任何经验,但我知道当你冻结 pandas 时,你需要明确包含 numpy。我将分享一个包含 pandas 的设置文件(以及我认为可以删除的其他一些内容,例如 boto)

import sys
import cx_Freeze
import os.path
import scipy

base = None

if sys.platform == 'win32':
    base = "Win32GUI"

#This part may depend on where your installation is
#This part is essential to copy the tkinter DLL files over
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')
os.environ['REQUESTS_CA_BUNDLE'] = r'C:\ProgramData\Anaconda3\Lib\site-packages\botocore\vendored\requests\cacert.pem'


executables = [cx_Freeze.Executable("test.py", base=base)]
addtional_mods = ['numpy.core._methods', 'numpy.lib.format']

packages = ["idna", "numpy", "boto3", 'boto3.s3.transfer', 'boto3.s3.inject', 'multiprocessing', "xlwt", 'numpy.core._methods', 'pandas']
options = {
    'build_exe': {

        'include_files':[
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),
            os.path.dirname(scipy.__file__),
            r'C:\ProgramData\Anaconda3\Lib\site-packages\botocore\vendored\requests\cacert.pem',
            r'C:\ProgramData\Anaconda3\Lib\site-packages\botocore',

         ],
        'includes': addtional_mods,
        'packages':packages,
    },

}

cx_Freeze.setup(
    name = "Test",
    options = options,
    version = "1.0.0.0",
    description = 'Test',
    executables = executables
)
Run Code Online (Sandbox Code Playgroud)