kedro: 0.19.1 `kedro new` failes to create new project. Raises KedroCliError: Failed to generate project when running cookiecutter
Description
Creating a new kedro project via kedro new --name my_project --verbose fails with the following error:
kedro.framework.cli.utils.KedroCliError: Failed to generate project when running cookiecutter. (full trace below)
Context
- I am trying to initiate a new project in a ‘clean’ conda environment with
kedro==0.19.1. I have no other environments (exceptbasewhich has only defaults installed), and no other kedro installs. - Cookiecutter is
2.5.0(installs with kedro) - I’m on Windows 10
Issue reproduces on kedro==0.19.0. Issue is absent on `kedro==0.18.14.
Steps to Reproduce
- conda create --name my_env python=3.11
- conda activate my_env
- (my_env) $ kedro new --name my_project–verbose
- select any/all/none tools (it fails on all options)
- select yes/no for example pipeline (it fails on both options )
Expected Result
A base new project should be created.
Actual Result
Project setup fails in Cookiecutter afaict.
Would you like to include an example pipeline? :
(no): yes
[01/21/24 20:56:13] ERROR Stopping generation because post_gen_project hook script didn't exit successfully hooks.py:159
Traceback (most recent call last):
File "C:\Users\bcech\anaconda3\envs\my_env\Lib\site-packages\kedro\framework\cli\starters.py", line 864, in _create_project
result_path = cookiecutter(template=template_path, **cookiecutter_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\bcech\anaconda3\envs\my_env\Lib\site-packages\cookiecutter\main.py", line 182, in cookiecutter
result = generate_files(
^^^^^^^^^^^^^^^
File "C:\Users\bcech\anaconda3\envs\my_env\Lib\site-packages\cookiecutter\generate.py", line 420, in generate_files
run_hook_from_repo_dir(
File "C:\Users\bcech\anaconda3\envs\my_env\Lib\site-packages\cookiecutter\hooks.py", line 152, in run_hook_from_repo_dir
run_hook(hook_name, project_dir, context)
File "C:\Users\bcech\anaconda3\envs\my_env\Lib\site-packages\cookiecutter\hooks.py", line 135, in run_hook
run_script_with_context(script, project_dir, context)
File "C:\Users\bcech\anaconda3\envs\my_env\Lib\site-packages\cookiecutter\hooks.py", line 118, in run_script_with_context
run_script(temp.name, cwd)
File "C:\Users\bcech\anaconda3\envs\my_env\Lib\site-packages\cookiecutter\hooks.py", line 89, in run_script
raise FailedHookException(
cookiecutter.exceptions.FailedHookException: Hook script failed (exit status: 1)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\bcech\anaconda3\envs\my_env\Lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Users\bcech\anaconda3\envs\my_env\Lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\bcech\anaconda3\envs\my_env\Lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\bcech\anaconda3\envs\my_env\Lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\bcech\anaconda3\envs\my_env\Lib\site-packages\kedro\framework\cli\starters.py", line 268, in new
_create_project(project_template, cookiecutter_args)
File "C:\Users\bcech\anaconda3\envs\my_env\Lib\site-packages\kedro\framework\cli\starters.py", line 866, in _create_project
raise KedroCliError(
kedro.framework.cli.utils.KedroCliError: Failed to generate project when running cookiecutter.
Your Environment
- Kedro version used (
pip show kedroorkedro -V):0.19.1,0.19.0 - Python version used (
python -V):3.11.7,3.10.13 - Operating system and version: Windows 10, build 19045.3930
- conda version: 23.7.4
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Reactions: 1
- Comments: 23 (14 by maintainers)
Finally, I think so!
kedro new ...via my Anaconda PowershellPopen(..., shell=True)is calling %COMSPEC% -> defaultC:\Windows\System32\cmd.execmd.exe(powershell is miserable enough…)C:\Windows\System32\cmd.exeis totally broken. No idea why or what happened.So. When I’ve been calling
script_command = ['C:\\Users\\bcech\\anaconda3\\envs\\kedro311\\python.exe', 'C:\\Users\\bcech\\AppData\\Local\\Temp\\tmpw31svgdv.py']manually (in my conda powershell), everything is hunky-dorey. But thesubprocess.Popen(...)call is trying to go tocmd.exe, which is indeed failing. This makes sense thatshell=Falseworks fine – python is called directly and the script runs as usual.I’ll fix that (my cmd.exe) when I’m able and confirm back here.
But, in the meantime, I’ll close this bug now. So sorry to litter up your Issue board with what is ultimately not looking like a Kedro bug at all. Thank you so much for your persistence on this.
What a wild ride.
So happy we got to the bottom of this! And no need to apologize @BrianCechmanek, I know how annoying these rabbit holes can get and glad that I could help you debug this nasty issue.
Maybe as a tribute do you want to send a PR to cookiecutter to amend this clunky setting? 😄
I can confirm that I am facing a similar issue on
windows 11,python=3.9.15,kedro==0.19.2. It looks like there is some tricky conversion on tools which sometimes generate an invalid pyproject.toml by removing quotes around the"tools": "['None']", don’t know why.Edit: Fun fact: it works if I always press enter without writing anything on each entry.
Thanks @astrojuanlu
I’ll have time in a day or two to debug it a bit more. I’ll see if it’s more one of Conda, Windows, Cookiecutter.
I’m not using python
3.12(as it’s not supported yet). I can reproduce this issue on python3.11and3.10. On Windows.conda info -a:conda env export --from-history:$ conda create --name kedro311 python=3.11and then(kedro311) $ python -m pip install kedro kedro-datasets kedro-viz numpy pandas torch ipykerneland lastly,
pip freeze:This was fixed in 0.19.2 (confirmed by another user), I’m closing @BrianCechmanek but if an upgrade still doesn’t do the trick please leave a comment and we’ll reconsider.