python - 使用 pip 安装后找不到 cookiecutter 命令

标签 python django cookiecutter-django

我想使用 cookiecutter 启动一个 django 项目,但由于某种原因找不到 cookiecutter。

我所做的是:

pip install cookiecutter

之后:

cookiecutter https://github.com/pydanny/cookiecutter-django

然后我收到错误信息:

    The program 'cookiecutter' is currently not installed. You can install it by typing:
    sudo apt install cookiecutter

但是,当我使用 apt 安装 cookiecutter 并运行 cookiecutter https://github.com/pydanny/cookiecutter-django 时,我收到一个错误。

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 "./LICENSE", line 3, in template
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'now'. Jinja was looking for the following tags: 'elif' or 'else' or 'endif'. The innermost block that needs to be closed is 'if'.
  File "./LICENSE", line 3
    Copyright (c) {% now 'utc', '%Y' %}, {{ cookiecutter.author_name }}

我知道这与 cookiecutter 的版本有关,它必须 >=1.4
pip 包是 1.4 版,但不会运行。

我在这里错过了什么?

我正在使用 virtualbox,因此这不在 virtualenv 中。

最佳答案

你也可以运行它

python -m cookiecutter https://github.com/pydanny/cookiecutter-django

关于python - 使用 pip 安装后找不到 cookiecutter 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38172539/

相关文章:

python - 无法从另一个 python 代码访问 ListField 元素

python - Elasticsearch DSL 中动态生成的 DocType

python - 尝试访问 uWSGI 上的 Flask-Admin 时出现 404 Not Found

jquery - 如何使用 Django + jQuery 修复 XSS?

python - Django/Apache 设置给我一个 'module not found' 错误

python - 有效计算笛卡尔积中总和高于特定数字的集合

sql - 为什么此Django原始SQL查询未返回输出?

python - 外壳错误 : doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS

django - 您何时需要将--no-cache与docker-compose build for django一起使用

python - 无法将变量从应用程序中的另一个模板传递给 Django 主页模板