gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 12:01:19 32 4
gpt4 key购买 nike

我的程序在 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)])

请帮忙。

最佳答案

我对 xgboost 没有任何经验,但我知道当你 cx freeze 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
)

关于python - 带有 tkinter xgboost 的 cxfreeze 小部件未显示但没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47853468/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com