Python使用cx_Freeze库生成msi格式安装文件的方法

远远地眺望,草地上有团团白云在蠕动,原来这是牧场的羊群,一只只白生生的,肥壮可爱,使草原更加生的小鸟儿唧唧喳机勃勃。

本文实例讲述了Python使用cx_Freeze库生成msi格式安装文件的方法。分享给大家供大家参考,具体如下:

①.需要在目录下面创建一个文件 。setup.py

②.写入代码:

import sys
from cx_Freeze import setup, Executable
import os
os.environ['TCL_LIBRARY'] = r'C:\Python36-32\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Python36-32\tcl\tk8.6'
include_files=[
  r'C:\Python36-32\DLLs\tcl86t.dll',
  r'C:\Python36-32\DLLs\tk86t.dll'
]
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"],"include_files":include_files}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
  base = "Win32GUI"
setup(name="video1",#打完包后取的名字
   version="2.1",#版本
   description="aaaaa",#描述
   options={"build_exe": build_exe_options},
   executables=[Executable("video.py", base=base)])

③.命令:

python setup.py bdist_msi 生成安装包以及直接运行的exe文件

python setup.py build 生成exe可执行程序

注:此处使用的cx_Freeze库可使用pip命令安装:

pip install cx_Freeze

此外,若使用Python2.7环境下安装时提示Python error: Microsoft Visual C++ 9.0 is required ,则需要安装一个Micorsoft Visual C++ Compiler for Python 2.7 的包,即可解决问题。

希望本文所述对大家Python程序设计有所帮助。

以上就是Python使用cx_Freeze库生成msi格式安装文件的方法。很多人爱着爱着,爱了全世界,可唯独忘了爱自己。更多关于Python使用cx_Freeze库生成msi格式安装文件的方法请关注haodaima.com其它相关文章!

您可能有感兴趣的文章
Python自动化运维-使用Python脚本监控华为AR路由器关键路由变化

Python自动化运维-netmiko模块设备自动发现

Python自动化运维—netmiko模块连接并配置华为交换机

Python自动化运维-利用Python-netmiko模块备份设备配置

Python自动化运维-Paramiko模块和堡垒机实战