使用Pyinstaller创建Flask可执行文件

问题描述 投票:0回答:1

我已经创建了一个在本地服务器上运行的flask应用程序。我需要使用pyinstaller将其转换为单个可执行文件。

我在Pycharm中运行了以下命令:

pyinstaller -w -F --add-data "templates;templates" --add-data "static;static" app.py

但是,我不断收到值错误,提示未找到app.py。我以为app.py是包含我的整个flask应用程序的可执行文件的新名称。因此,我不确定为什么会不断收到值错误。

以下是我的烧瓶应用程序的目录结构:

Form
- migrations
- venv
- - app
- - - static
- - - templates
- - - Bunch of .py files
- microform.py
- config.py

我尝试跑步

pyinstaller -w -F --add-data "templates;templates" --add-data "static;static" microform.py

但随后我得到一个错误提示:

Unable to find "C:\Users\test\PycharmProjects\Form\templates" when adding binary and data files.
python flask executable
1个回答
0
投票

您应该在主文件中运行pyinstaller命令,在其中调用所有函数和类。

您可以检查以下链接:

https://datatofish.com/executable-pyinstaller/

© www.soinside.com 2019 - 2024. All rights reserved.