Avaiga / taipy-gui

Graphical User Interface generator for Taipy
Apache License 2.0
60 stars 18 forks source link

BUG-jinja2.exceptions.TemplateNotFound: index.html when starting gui web server #752

Closed arcanaxion closed 1 year ago

arcanaxion commented 1 year ago

Description Installing the current develop branch of taipy-gui, starting a simple application then opening the webpage shows:

image

Terminal shows jinja2.exceptions.TemplateNotFound: index.html (full traceback below).

How to reproduce

# main.py
from taipy.gui import Gui

Gui(page="Hello, world").run()
> pyenv shell 3.10
> python -m venv .venv
> source .venv/bin/activate
> pip install "git+https://git@github.com/avaiga/taipy-gui"
> python main.py

Current taipy-gui commit: 58a25ca61056f1b73f158329bf8a068af063ef75

Expected behavior Hello world should display on page as normal.

Traceback:

basic-taipy-app  | [2023-05-19 01:25:08][Taipy][INFO]  * Server starting on http://localhost:5000
basic-taipy-app  | [2023-05-19 01:25:39][Taipy][ERROR] Exception on / [GET]
basic-taipy-app  | Traceback (most recent call last):
basic-taipy-app  |   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2529, in wsgi_app
basic-taipy-app  |     response = self.full_dispatch_request()
basic-taipy-app  |   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1825, in full_dispatch_request
basic-taipy-app  |     rv = self.handle_user_exception(e)
basic-taipy-app  |   File "/usr/local/lib/python3.10/site-packages/flask_cors/extension.py", line 165, in wrapped_function
basic-taipy-app  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
basic-taipy-app  |   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
basic-taipy-app  |     rv = self.dispatch_request()
basic-taipy-app  |   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
basic-taipy-app  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
basic-taipy-app  |   File "/usr/local/lib/python3.10/site-packages/taipy/gui/server.py", line 150, in my_index
basic-taipy-app  |     return render_template(
basic-taipy-app  |   File "/usr/local/lib/python3.10/site-packages/flask/templating.py", line 146, in render_template
basic-taipy-app  |     template = app.jinja_env.get_or_select_template(template_name_or_list)
basic-taipy-app  |   File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 1081, in get_or_select_template
basic-taipy-app  |     return self.get_template(template_name_or_list, parent, globals)
basic-taipy-app  |   File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 1010, in get_template
basic-taipy-app  |     return self._load_template(name, globals)
basic-taipy-app  |   File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 969, in _load_template
basic-taipy-app  |     template = self.loader.load(self, name, self.make_globals(globals))
basic-taipy-app  |   File "/usr/local/lib/python3.10/site-packages/jinja2/loaders.py", line 126, in load
basic-taipy-app  |     source, filename, uptodate = self.get_source(environment, name)
basic-taipy-app  |   File "/usr/local/lib/python3.10/site-packages/flask/templating.py", line 62, in get_source
basic-taipy-app  |     return self._get_source_fast(environment, template)
basic-taipy-app  |   File "/usr/local/lib/python3.10/site-packages/flask/templating.py", line 98, in _get_source_fast
basic-taipy-app  |     raise TemplateNotFound(template)
basic-taipy-app  | jinja2.exceptions.TemplateNotFound: index.html

Runtime environment

dinhlongviolin1 commented 1 year ago

Hi @arcanaxion,

Since you are installing taipy-gui directly from the develop branch, you will need Node.js to be able to properly install the package. Make sure that your machine has node.js installed and you will be fine. You can have a look at this Dockerfile

FROM python:3.10.11-bullseye

# Setup Node.js 18
RUN apt-get update
RUN apt-get install curl
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash
RUN apt-get install nodejs

# installing taipy gui from develop branch
RUN pip install "git+https://git@github.com/avaiga/taipy-gui"

COPY main.py .

CMD [ "python" , "main.py"]

Let me know if this resolve your issue.

arcanaxion commented 1 year ago

Hi @dinhlongviolin1 , thanks for your reply.

I did recall you mentioning previously about needing node.js to install from the develop branch, so I did in fact previously ensure that I had some version of node.js installed on all my WSL instances and Docker images that I tested on when I opened this issue. I can also confirm that as of 3 days ago, I reattempted installing the package -- and they work.

I'm not sure what the difference was between then and now, but feel free to close the issue. If it happens again, I'll try to provide more details.

Also, I wonder if it's reasonable to generate some error message when installing the dev version of taipy-gui without node.js so that people that overlooked INSTALLATION.md may be hinted towards the issue.