python - 将 .py 文件转换为 .exe 文件
问题描述
我们在 .py 文件中导入了人脸识别模块,如何将该 .py 文件转换为可执行文件?我们还有一些 .txt 文件,我们为其提供了项目路径本身。如何将该本地路径更改为全局路径并转换为可执行文件?
解决方案
可执行文件的步骤如下所示 - 安装cx_freeze
然后创建文件setup.py
并粘贴以下内容 -
build_exe_options = {"includes": ["tkinter"]}
base = None
if sys.platform == "win32":
base = "Win32GUI"
from cx_Freeze import setup, Executable
setup(name = "<name-of-executable-file.exe>" ,
version = "<your-version-number>" ,
description = "<suitable-description>" ,
options={"build_exe": build_exe_options},
executables = [Executable("<your-python-file.py>", base=base)])
python setup.py build
在您的终端中运行。
推荐阅读
- html - 为什么 ::first-letter 是伪元素而不是伪类?
- workflow - 哪些变化使蛇形管道无效
- c# - 移动客户端将控制/发送命令到我的电脑服务器客户端
- python - 更改熊猫数据框中对象的属性
- javascript - 我可以将正文滚动条移动到特定 HTML 元素的左侧吗?
- java - 按名称对表格进行排序并在表格顶部显示名称
- angular - Angular 中 @Input 的派生默认值
- rust - Rust 会去虚拟化 trait 对象函数调用吗?
- python - 根据多维数组中元素的出现次数执行过程
- reactjs - 为什么我的 Formik 表单没有显示警告信息?反应,福米克