pythonflaskpyinstallerpython-standalone

TemplateNotFound jinja2.exceptions.TemplateNotFound: login.html


this the error which is occurring after the code is converted to exe file

the error exception the code

Traceback (most recent call last):
  File "flask\app.py", line 2213, in _call_
  File "flask\app.py", line 2193, in wsgi_app
  File "flask\app.py", line 2190, in wsgi_app
  File "flask\app.py", line 1486, in full_dispatch_request
  File "flask\app.py", line 1484, in full_dispatch_request
  File "flask\app.py", line 1469, in dispatch_request
  File "app.py", line 122, in login
  File "flask\templating.py", line 150, in render_template
  File "jinja2\environment.py", line 1081, in get_or_select_template
  File "jinja2\environment.py", line 1010, in get_template
  File "jinja2\environment.py", line 969, in _load_template
  File "jinja2\loaders.py", line 126, in load
  File "flask\templating.py", line 64, in get_source
  File "flask\templating.py", line 98, in _get_source_fast
jinja2.exceptions.TemplateNotFound: login.html


Solution

  • Try using the --add-data flag to your pyinstaller command with the path to the templates folder as the argument.

    For example:

    pyinstaller --onefile --add-data "./templates;./templates" app.py
    

    Use : as the path separator if you are using linux of mac.