Pyinstaller-未找到Flask模板“ bootstrap / base.html”

时间:2019-11-16 22:29:58

标签: pyinstaller flask-bootstrap

我正在尝试分发烧瓶应用程序。在本地运行时,一切正常。当使用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所示。

1 个答案:

答案 0 :(得分:0)

创建一个名为“ 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 .)