Python 无法使用cx_freeze和PySide2进行编译
我有一个python程序,我正试图用cx\u freeze编译。我使用的GUI是PySide2 我尝试过包括PySide2,这里是排除它,但我一直得到相同的错误。下面是我的setup.py代码Python 无法使用cx_freeze和PySide2进行编译,python,cx-freeze,pyside2,Python,Cx Freeze,Pyside2,我有一个python程序,我正试图用cx\u freeze编译。我使用的GUI是PySide2 我尝试过包括PySide2,这里是排除它,但我一直得到相同的错误。下面是我的setup.py代码 from cx_Freeze import setup, Executable import sys includefiles = ['README.md', 'debug.log','tcl86t.dll', 'tk86t.dll', 'field.jpg', 'inputClass.py', 'm
from cx_Freeze import setup, Executable
import sys
includefiles = ['README.md', 'debug.log','tcl86t.dll', 'tk86t.dll', 'field.jpg', 'inputClass.py', 'mainfile.qml', 'MyTabView.qml', 'PlayerSelection.qml', 'selectedPlayers.py', 'Settings.qml', 'SimOutput.qml', 'simulationOutput.py']
includes = ["idna.idnadata", "atexit"]
excludes = ["PySide2"]
import os
os.environ['TCL_LIBRARY'] = r'C:\Users\pimat\AppData\Local\Programs\Python\Python36\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\pimat\AppData\Local\Programs\Python\Python36\tcl\tk8.6'
setup(name = "Simulation",
version = "0.2",
description = "Optimization Simulator",
options = {'build_exe':{'includes':includes,'excludes':excludes,'include_files':includefiles}},
executables = [Executable("main.py")])
该程序编译良好,但在运行exe时,出现以下错误:
“ModuleNotFoundError:没有名为'PySide2'的模块”
因此,错误是我安装了带有Python3.6的cx_freeze,但我的所有软件包都在Python3.7文件夹中。我只是简单地复制并粘贴到3.6文件夹中,并对代码做了一些修改,exe运行得非常好
from cx_Freeze import setup, Executable
import sys
# dependencies
build_exe_options = {
"packages": ["os", "sys", "re", "idna.idnadata", "atexit", "PySide2.QtCore", "PySide2.QtWidgets", "PySide2.QtUiTools", "PySide2.QtQuick", "PySide2.QtQml", "PySide2.QtGui", "shiboken2"],
"include_files": ['README.md', 'debug.log','tcl86t.dll', 'tk86t.dll', 'field.jpg', 'inputClass.py', 'mainfile.qml', 'MyTabView.qml', 'PlayerSelection.qml', 'selectedPlayers.py', 'Settings.qml', 'SimOutput.qml', 'simulationOutput.py',
],
"excludes": ["Tkinter", "Tkconstants", "tcl", ],
"build_exe": "build",
#"icon": "./example/Resources/Icons/monitor.ico"
}
executable = [
Executable("main.py",
base="Win32GUI",
targetName="Simulation.exe"
)
]
setup(name = "Simulation",
version = "0.2",
description = "Simulator",
options={"build_exe": build_exe_options},
executables=executable
)
这是个愚蠢的错误,但我犯了更糟的错误