我正在尝试使用 cx_Freeze
构建我的GUI应用程序。以下是 setup.py
的代码:
from cx_Freeze import setup, Executable
import os
import sys
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
exe = [Executable("main.py", base=base, icon='window_icon_XbH_icon.ico')]
os.environ['TCL_LIBRARY'] = r'C:\\Users\\dm\\AppData\\Local\\Programs\\Python\\Python36\\tcl\\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\\Users\\dm\\AppData\\Local\\Programs\\Python\\Python36\\tcl\\tk8.6'
options = {
'build_exe': {
'includes': ['scipy.io', 'scipy.spatial.ckdtree'],
'include_files': [r'C:\\Users\\dm\\AppData\\Local\\Programs\\Python\\Python36\\DLLs\\tcl86t.dll', r'C:\\Users\\dm\\AppData\\Local\\Programs\\Python\\Python36\\DLLs\\tk86t.dll',
r'C:\\Users\\dm\\AppData\\Local\\Programs\\Python\\Python36\\Lib\\site-packages\\pyqt5_tools\\platforms\\qwindows.dll', 'window_icon_XbH_icon.ico'],
'packages': ['pkg_resources._vendor', 'pandas', 'numpy', 'scipy', 'pydub', 'PyQt5', 'soundfile', 'sounddevice', 'cffi'],
}
}
setup(name="app", version="1.0", description='To be added',
options=options, executables=exe)
在构建过程中,cx_Freeze出现了以下错误。我已经安装了PyQt5。
running build
running build_exe
Traceback (most recent call last):
File "setup.py", line 38, in <module>
options=options, executables=exe)
File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\dist.py", line 349, in setup
distutils.core.setup(**attrs)
File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\dist.py", line 219, in run
freezer.Freeze()
File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py", line 616, in Freeze
self.finder = self._GetModuleFinder()
File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py", line 342, in _GetModuleFinder
finder.IncludePackage(name)
File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 659, in IncludePackage
module = self._ImportModule(name, deferredImports)
File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 351, in _ImportModule
raise ImportError("No module named %r" % name)
ImportError: No module named 'PyQt5.Qt'
能否有人帮助我找出实际上出了什么问题?