Python 代码调用 PyInstaller 打包指定 .py 文件
要使用 Pyinstaller 打包指定的 Python 文件,可以使用以下代码:
import PyInstaller.__main__
PyInstaller.__main__.run([
'--name='your_app_name',
'--onefile',
'path_to_your_python_file.py'
])
在上面的代码中,将'your_app_name'替换为您的应用程序的名称,'path_to_your_python_file.py'替换为要打包的 Python 文件的路径。
运行上述代码后,PyInstaller 将使用默认配置将 Python 文件打包为一个可执行文件,该文件将在与 Python 文件相同的目录中生成。
原文地址: https://www.cveoy.top/t/topic/phW9 著作权归作者所有。请勿转载和采集!