【问题标题】:Pyinstaller - Flask template not found "bootstrap/base.html"Pyinstaller - 找不到 Flask 模板“bootstrap/base.html”
【发布时间】:2020-02-16 22:54:06
【问题描述】:

我正在尝试制作一个可分发的烧瓶应用程序。在本地运行时一切正常。当使用 pyinstaller 生成可执行文件时,它会给我错误:

 Traceback (most recent call last):
  File "site-packages\flask\app.py", line 2446, in wsgi_app

  File "site-packages\flask\app.py", line 1951, in full_dispatch_request
  File "site-packages\flask\app.py", line 1820, in handle_user_exception
  File "site-packages\flask\_compat.py", line 39, in reraise
  File "site-packages\flask\app.py", line 1949, in full_dispatch_request
  File "site-packages\flask\app.py", line 1935, in dispatch_request
  File "app.py", line 39, in index
  File "site-packages\flask\templating.py", line 140, in render_template
  File "site-packages\flask\templating.py", line 120, in _render
jinja2.exceptions.TemplateNotFound: bootstrap/base.html

我正在使用烧瓶引导程序,如图所示here

【问题讨论】:

标签: pyinstaller flask-bootstrap


【解决方案1】:

创建一个名为“hook-flask_bootstrap.py”的新python文件,在此粘贴以下内容:

from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('flask_bootstrap')

现在,当您运行 pyinstaller 时,请提供此“hook-flask_bootstrap.py”文件的路径:

--additional-hooks-dir=PATH (If relative path, just use .)

【讨论】:

  • 感谢您的回答。后来我决定不使用烧瓶引导程序,而是使用 HTML 中的引导程序设计网页。虽然我没有对此进行测试,但我希望这对来到这里的人有用。
  • 我试过这个,它对我有用。谢谢特里斯汀。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-06-13
  • 1970-01-01
  • 2018-01-16
  • 1970-01-01
  • 2014-06-07
  • 2017-12-14
  • 1970-01-01
相关资源
最近更新 更多