使用cx_freeze
- 新建setup.py文件,添加内容
import sys
from cx_Freeze import setup, Executable
import os
import scipy
path = sys.path
# Dependencies are automatically detected, but it might need fine tuning.
package = ['pyface.ui.qt4', 'tvtk',
'tvtk.pyface.ui.qt4',
'pyface.qt', 'numpy',
'matplotlib', 'mayavi', 'traits', 'traitsui',
'scipy', 'scipy.linalg', 'PyQt5']
excludes = ['gtk', 'Tkinter', 'wx']
includes = ['matplotlib.backends.backend_qt5', 'tvtk.vtk_module', 'traitsui.toolkit', 'traitsui.toolkit_traits', 'mayavi.mlab',
'pyface.qt.QtCore', 'pyface.qt.QtGui', 'pyface.qt.QtNetwork', 'pyface.qt.QtOpenGL', 'pyface.qt.QtScript',
'pyface.qt.QtSvg', 'pyface.qt.QtTest', 'pyface.qt.QtWebKit',
'PyQt5.QtCore', 'PyQt5.QtGui', 'PyQt5.Qt', 'PyQt5.QtWidgets', 'PyQt5.QtOpenGL', 'PyQt5.QtSvg',
'PyQt5.QtTest',
'PyQt5.QtPrintSupport']
scipy_path = os.path.dirname(scipy.__file__)
includefiles = [(str(scipy_path), "scipy")]
build_exe_options = {"packages": package,
"excludes": excludes,
"includes": includes,
"include_files": includefiles,
"namespace_packages": ['mayavi']
}
os.environ['ETS_TOOLKIT'] = 'qt'
filename = r'D:\qjd\pro\GNSS\GNSS\main\iono_inversion.py'
base = None
if sys.platform == "win32":
base = "Win32GUI"
cible = Executable(
script=filename,
targetName='iono.exe',
base=base,
)
setup(name="iono",
version="0.1",
description="iono",
options={"build_exe": build_exe_options},
executables=[cible])
2、执行python setup.py bdist_msi
3.复制Lib\site-packages 到 build\exe.win-amd64-3.8目录下