使用 pip 安装后找不到 cookiecutter 命令
cookiecutter command not found after installing with pip
我想使用 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 https://github.com/pydanny/cookiecutter-django
安装 cookiecutter 时,出现错误。
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 中。
抱歉,您好像搞错了。
- 因为
sudo apt-get install cookiecutter
安装了一些东西
称为 cookiecutter 并不意味着它是同一个 cookiecutter
点子。事实上,他们没有任何共同点。一个是 python 的曲奇切割器,另一个是 django 的。
- 这是千篇一律的
在 launchpad 上,你用 apt-get 安装的那个:
https://launchpad.net/ubuntu/+source/cookiecutter
- 这就是
您正在寻找:https://pypi.python.org/pypi/cookiecutter-django
回到你的问题:
如果您不想让自己头疼,即使您在 Virtualbox 中工作,设置 VirtualEnv 来处理项目的封装也没有错。
我只是根据对您问题的理解,复制并在几秒钟内完成了所有工作。
mkvirtualenv myProject
(假设您安装了 virtualenv 和 virtualenvwrapper,添加到 ~/.bashrc
并重新启动 bash,重新启动终端 gui,或 souce ~/.bashrc
workon myProject
- 然后在
(myProject) $~
提示符下,继续安装,即:
sudo apt install python-pip
pip install cookiecutter
- 然后照常进行,
cookiecutter https://github.com/pydanny/cookiecutter-django.git
除非您计划为每个要启动的 Django 项目启动 Ubuntu virtualbox 实例,否则我建议您使用 virtualenv 来保持清洁。
您也可以 运行 使用
python -m cookiecutter https://github.com/pydanny/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 https://github.com/pydanny/cookiecutter-django
安装 cookiecutter 时,出现错误。
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 中。
抱歉,您好像搞错了。
- 因为
sudo apt-get install cookiecutter
安装了一些东西 称为 cookiecutter 并不意味着它是同一个 cookiecutter 点子。事实上,他们没有任何共同点。一个是 python 的曲奇切割器,另一个是 django 的。 - 这是千篇一律的 在 launchpad 上,你用 apt-get 安装的那个: https://launchpad.net/ubuntu/+source/cookiecutter
- 这就是 您正在寻找:https://pypi.python.org/pypi/cookiecutter-django
回到你的问题:
如果您不想让自己头疼,即使您在 Virtualbox 中工作,设置 VirtualEnv 来处理项目的封装也没有错。
我只是根据对您问题的理解,复制并在几秒钟内完成了所有工作。
mkvirtualenv myProject
(假设您安装了 virtualenv 和 virtualenvwrapper,添加到~/.bashrc
并重新启动 bash,重新启动终端 gui,或souce ~/.bashrc
workon myProject
- 然后在
(myProject) $~
提示符下,继续安装,即: sudo apt install python-pip
pip install cookiecutter
- 然后照常进行,
cookiecutter https://github.com/pydanny/cookiecutter-django.git
除非您计划为每个要启动的 Django 项目启动 Ubuntu virtualbox 实例,否则我建议您使用 virtualenv 来保持清洁。
您也可以 运行 使用
python -m cookiecutter https://github.com/pydanny/cookiecutter-django