我想创建脚本的.exe,以便能够轻松将其分发给其他用户。安装Mayavi依赖项不是那么简单,因此创建.exe会很简单。我一开始尝试pyinstaller,但没有运气。我尝试使用cx_freeze,但收到的错误是“ ModuleNotFoundError:没有模块名称'mpl_toolskits'
我已附上我使用的安装文件:
import os
from cx_Freeze import setup, Executable
import cx_Freeze.hooks
def hack(finder, module):
return
cx_Freeze.hooks.load_matplotlib = hack
# import scipy
import matplotlib
# scipy_path = os.path.dirname(scipy.__file__)
build_exe_options = {"packages": ["pyface.ui.qt4", "tvtk.vtk_module", "tvtk.pyface.ui.wx", "matplotlib.backends.backend_qt4",'pygments.lexers',
'tvtk.pyface.ui.qt4','pyface.qt','pyface.qt.QtGui','pyface.qt.QtCore','numpy','matplotlib','mayavi'],
"include_files":[(matplotlib.get_data_path(), "mpl-data")],
"includes":['PySide2.QtCore','PySide2.QtGui','mayavi','PySide2'],
'excludes':'Tkinter',
"namespace_packages": ['mayavi']
}
executables = [
Executable('3D Visualizer Working.py', targetName="Horn Visualizer.exe",base = 'Win32GUI',)
]
setup(name='3D Visualizer',
version='1.0',
description='',
options = {"build_exe": build_exe_options},
executables=executables,
)
在主脚本中,我使用的是Mayavi,numpy,matplotlib,qt4,xlrd,pyface和pyside2。
非常感谢任何人提供有关此问题的帮助,谢谢!