Closed xhluca closed 5 years ago
You don't need virtualenv for python 3, it uses the stdlib venv module. I'll update the message. I just tried from windows and python 3.6 and the venv command worked. I see conda, I think that the venv it ships with is different as it have it's own commands to create environments, try from a regular python interpreter.
Interesting. I just run the example again (on W10), but this time after creating a venv and only installing virtualenv
and cookiecutter
. I ran this command:
cookiecutter git@github.com:plotly/dash-component-boilerplate.git
And got this error:
(test) C:\Users\xingh\temp>cookiecutter git@github.com:plotly/dash-component-boilerplate.git
Traceback (most recent call last):
File "c:\users\xingh\appdata\local\continuum\anaconda3\Lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\xingh\appdata\local\continuum\anaconda3\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\xingh\temp\test\Scripts\cookiecutter.exe\__main__.py", line 9, in <module>
File "c:\users\xingh\temp\test\lib\site-packages\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "c:\users\xingh\temp\test\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\users\xingh\temp\test\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\xingh\temp\test\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\users\xingh\temp\test\lib\site-packages\cookiecutter\cli.py", line 120, in main
password=os.environ.get('COOKIECUTTER_REPO_PASSWORD')
File "c:\users\xingh\temp\test\lib\site-packages\cookiecutter\main.py", line 63, in cookiecutter
password=password
File "c:\users\xingh\temp\test\lib\site-packages\cookiecutter\repository.py", line 103, in determine_repo_dir
no_input=no_input,
File "c:\users\xingh\temp\test\lib\site-packages\cookiecutter\vcs.py", line 99, in clone
stderr=subprocess.STDOUT,
File "c:\users\xingh\appdata\local\continuum\anaconda3\Lib\subprocess.py", line 336, in check_output
**kwargs).stdout
File "c:\users\xingh\appdata\local\continuum\anaconda3\Lib\subprocess.py", line 418, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['git', 'clone', 'git@github.com:plotly/dash-component-boilerplate.git']' returned non-zero exit status 128.
To solve this I had to do
git clone https://github.com/plotly/dash-component-boilerplate.git
cookiecutter dash-component-boilerplate
That is because of the git ssh url, you'd need to setup ssh for that. Try with https:
$ cookiecutter https://github.com/plotly/dash-component-boilerplate.git
So two tasks here:
Thank you! 👍
For anaconda any idea if it's caused by cookiecutter or virtualenv, and if it's something easy to solve? I prefer to use anaconda as my main interpreter and don't have the regular interpreter installed, so it's a hassle to play with pythonpath every time i need to use cookiecutter.
For anaconda any idea if it's caused by cookiecutter or virtualenv, and if it's something easy to solve?
Yeah, it'd be good to solve it for conda users since it's relatively popular in the dash community
I've got the same problem as @xhlulu
emma@hopper:~/sandbox$ cookiecutter https://github.com/plotly/dash-component-boilerplate.git
You've downloaded /home/emma/.cookiecutters/dash-component-boilerplate before. Is it okay to delete and re-download it? [yes]:
project_name [my dash component]: Dash Core Component
project_shortname [dash_core_component]:
component_name [DashCoreComponent]:
author_name [Enter your name (For package.json)]: emma
author_email [Enter your email (For package.json)]: emma@nsup.org
description [Project Description]: bla
Select 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, 2, 3, 4, 5, 6) [1]: 2
publish_on_npm [True]: False
install_dependencies [True]:
Patching build command
Executing: python -m venv venv
/usr/bin/python: No module named venv
post_gen_project command failed: python -m venv venv
venv creation failed
Make sure you have installed virtualenv on python 2.
ERROR: Stopping generation because post_gen_project hook script didn't exit successfully
Hook script failed (exit status: 1)
I have both python2 and python3 on my computer, although I work with python3. "python" stands for python 2.7. How can I force cookiecutter to use python 3?
@emmanuelle That is on linux/mac with conda ?
@T4rk1n A temporary fix is to modify post_gen_project.py
inside hooks:
@emmanuelle I think in your case you can replace venv = 'python -m venv venv'
with venv = 'python3 -m venv venv'
. You can try it out on a fork.
Thanks @xhlulu and @T4rk1n modifying the post_gen_project.py
script did the trick. I'm using pip3, not conda. Thanks for your help :-)
You are welcome!
Can we make the python alias another cookiecutter
input, so you can just enter python3
if that's how you have it set up to invoke Python? Or perhaps better, though less flexible, just use sys.executable
?
@alexcjohnson Yes, that is what I was planning, I think the whole dependencies installation can be refactored. Also with https://github.com/plotly/dash/pull/451 we can remove some part of it.
that is what I was planning
which "that"? Another input or sys.executable
?
Another input.
Not sure if that's an intended behavior. I only have Python 3 installed, along with latest cookiecutter and virtualenv versions. Here's the full output: