audreyfeldroy / cookiecutter-pypackage

Cookiecutter template for a Python package.
BSD 3-Clause "New" or "Revised" License
4.26k stars 1.78k forks source link

Error, when generating from template, on ubuntu 16.04 LTS #194

Closed mjscosta closed 8 years ago

mjscosta commented 8 years ago

Generate template from https://github.com/audreyr/cookiecutter-pypackage.

What I Did

cookiecutter https://github.com/audreyr/cookiecutter-pypackage

full_name [Audrey Roy Greenfeld]: <my name>
email [aroy@alum.mit.edu]: <my email>@gmail.com
github_username [audreyr]: <my user name>
project_name [Python Boilerplate]: <my project name>
project_slug [...]: 
project_short_description [Python Boilerplate contains all the boilerplate you need to create a Python package.]: 
pypi_username [...]: 
version [0.1.0]: 
use_pytest [n]: 
use_pypi_deployment_with_travis [y]: 
Select command_line_interface:
1 - Click
2 - No command-line interface
Choose from 1, 2 [1]: 
create_author_file [y]: 
Select open_source_license:
1 - MIT license
2 - BSD license
3 - ISC license
4 - Apache Software License 2.0
5 - GNU General Public License v3
6 - Not open source
Choose from 1, 2, 3, 4, 5, 6 [1]: 
Traceback (most recent call last):
  File "/usr/bin/cookiecutter", line 9, in <module>
    load_entry_point('cookiecutter==1.3.0', 'console_scripts', 'cookiecutter')()
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/cookiecutter/cli.py", line 100, in main
    config_file=user_config
  File "/usr/lib/python2.7/dist-packages/cookiecutter/main.py", line 140, in cookiecutter
    output_dir=output_dir
  File "/usr/lib/python2.7/dist-packages/cookiecutter/generate.py", line 327, in generate_files
    generate_file(project_dir, infile, context, env)
  File "/usr/lib/python2.7/dist-packages/cookiecutter/generate.py", line 167, in generate_file
    tmpl = env.get_template(infile_fwd_slashes)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 812, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 786, in _load_template
    template = self.loader.load(self, name, globals)
  File "/usr/lib/python2.7/dist-packages/jinja2/loaders.py", line 125, in load
    code = environment.compile(source, name, filename)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 565, in compile
    self.handle_exception(exc_info, source_hint=source_hint)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "./HISTORY.rst", line 5, in template
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'now'.
  File "./HISTORY.rst", line 5
    {{ cookiecutter.version }} ({% now 'local' %})
eliasdorneles commented 8 years ago

Hello @mjscosta ! You need to use cookiecutter with version >= 1.4.0, that introduced support for jinja2-time extensions. Thanks for reporting, I'll make this requirement explicit in requirements_dev.txt.

mjscosta commented 8 years ago

Hi, @audreyr, @eliasdorneles, I then solved the issue, not sure how, but it was related with my environment ... maybe, is the default ubuntu cookiecutter package (http://packages.ubuntu.com/xenial/cookiecutter, 1.3.0).