0

I am trying to make a distributable flask application. Everything works fine when running locally.

When an executable is generated with pyinstaller it gives me the error:

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

Some friends say:

create a new python file named 'hook-flask_bootstrap.py', inside of this paste the following:

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

Now when you run pyinstaller provide the path to this 'hook-flask_bootstrap.py' file:

I use command line:

**pyinstaller -D --i icon\crawler_spider72.ico --additional-hooks-dir hook-flask_bootstrap.py run.py**

I searched for some answers, but after using, there was no action collected. Don't know where the mistake is. Ask the knowledgeable person for advice. Thank you

Swati Garg
  • 995
  • 1
  • 10
  • 21
  • 1
    This question would be easier to answer with an example app. Try to reproduce the issue on the most minimal code possible in a new flask application. Publish the minimal sample project to a public source code repo like github. Include detailed steps for reproducing the error. Try out a pyinstaller flask tutorial that is known to work correctly, then look for differences between that and your sample. – Rick Suggs Feb 16 '20 at 17:47
  • First of all, thank you for answering my questions. Later, I found a similar situation in pyinstaller Q & A. Follow the prompts below to solve the problem. Thank you again. Hooks are placed in ./PyInstaller/hooks/ PyInstaller/utils/hooks is only for helper functions As an example you could use any file from PyInstaller/hooks that contains collect_data_files. It looks like you need hook like hook-flask_bootstrap.py: from PyInstaller.utils.hooks import collect_data_files datas = collect_data_files('flask_bootstrap') – hero cattle Feb 21 '20 at 06:57

0 Answers0