Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jinja2.exceptions.TemplateNotFound: sections\education.tex (On Windows?) #11

Closed
rlabrecque opened this issue Feb 25, 2015 · 7 comments
Closed

Comments

@rlabrecque
Copy link

I'm looking into this cv project for myself, but it doesn't seem to work out of the box, at least on windows.

I end up with this:

D:\Riley\Desktop\cv-master>generate.py -p cv.yaml
  + Processing section: interests
  + Processing section: education
Traceback (most recent call last):
  File "D:\Riley\Desktop\cv-master\generate.py", line 289, in <module>
    main()
  File "D:\Riley\Desktop\cv-master\generate.py", line 284, in main
    process_resume(LATEX_CONTEXT, yaml_data, args.preview)
  File "D:\Riley\Desktop\cv-master\generate.py", line 251, in process_resume
    rendered_resume = context.render_resume(yaml_data)
  File "D:\Riley\Desktop\cv-master\generate.py", line 199, in render_resume
    section_template_name, section_data)
  File "D:\Riley\Desktop\cv-master\generate.py", line 150, in _render_template
    return self._jinja_env.get_template(template_name).render(yaml_data)
  File "C:\Python34\lib\site-packages\jinja2\environment.py", line 791, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "C:\Python34\lib\site-packages\jinja2\environment.py", line 765, in _load_template
    template = self.loader.load(self, name, globals)
  File "C:\Python34\lib\site-packages\jinja2\loaders.py", line 113, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "C:\Python34\lib\site-packages\jinja2\loaders.py", line 160, in get_source
    pieces = split_template_path(template)
  File "C:\Python34\lib\site-packages\jinja2\loaders.py", line 31, in split_template_path
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: sections\education.tex

Any chance that I'm doing something wrong?
All I did was clone, pip3 install -r requirements.txt, generate.py cv.yaml

@bamos
Copy link
Owner

bamos commented Feb 25, 2015

Hi @rlabrecque - thanks for the report.

The code is written to be cross-platform, but I've
never tested in Windows before.
I think this is a subtle bug with the jinja templates.
I'll debug on a Windows machine today or tomorrow.

Afterwards, I'd like to set up Linux and Windows CI so
this won't be problem in the future.
I've filed #12 for this.

bamos pushed a commit that referenced this issue Feb 26, 2015
Thanks @mrobb - from https://github.com/mrobb/complexity/commit/912ca3ac2fa97deb427d529a452c805903f686d2

Jinja2's FileSystemLoader converts forward slashes to os.path.sep
automatically by design. This results in failures when using
env.get_template() on Windows.
@bamos
Copy link
Owner

bamos commented Feb 26, 2015

Hi @rlabrecque - can you pull the latest code and try again?
I think I've fixed the problem, caused by how Jinja's FileSystemLoader handles paths in Windows.

@rlabrecque
Copy link
Author

Yep, It's all good now! Thanks!

@bamos
Copy link
Owner

bamos commented Feb 26, 2015

\cc @emichael

@bamos bamos closed this as completed Feb 26, 2015
@emichael
Copy link

Huh, I don't quite understand what the problem was, and I'm curious. Did he have a folder/file with a forward slash in the path?

@bamos
Copy link
Owner

bamos commented Feb 26, 2015

@emichael - in windows, generate.py will create a string like
sections\education.tex (with backslashes from os.path.sep)
to retrieve and render a template with self._jinja_env.get_template.
I don't understand why, but Jinja's get_template method expects
the path to be separated with forward slashes, even in Windows.

This seems to be a problem in other projects too:
https://github.com/mrobb/complexity/commit/912ca3ac2fa97deb427d529a452c805903f686d2

@emichael
Copy link

Ugh. And I thought religious use of os.path.join would prevent such nonsense...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants