Python zipapp with data files

144 Views Asked by At

I created a .pyz application, here is the structure:

myapp
┣ templates
┃ ┗ index.j2
┗ main.py

In main program i have this:

j2_env = jinja2.Environment(loader=jinja2.FileSystemLoader('templates'), trim_blocks=True)
st = j2_env.get_template('index.j2').render()

When trying to execute the program I receive error: jinja2.exceptions.TemplateNotFound: index.j2

How to get access to template directory inside the zipapp? It works perfectly using .py file, outside of package.

0

There are 0 best solutions below