venv creation broken on Windows with spaces in python path
These lines to generate the virtual environment didn't work on my machine.
My python.exe is at c:\program files\python37\python.exe. Here's the error I get:
C:\temp_workspace\dash_temp>cookiecutter gh:plotly/dash-component-boilerplate
You've downloaded C:\Users\reube\.cookiecutters\dash-component-boilerplate before. Is it okay to delete and re-download it? [yes]:
project_name [my dash component]: test
project_shortname [test]:
component_name [Test]:
jl_prefix []:
r_prefix []:
author_name [Enter your first and last name (For package.json)]: test
author_email [Enter your email (For package.json)]: [email protected]
github_org []:
description [Project Description]: test
Select use_async:
1 - False
2 - True
Choose from 1, 2 [1]:
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]:
publish_on_npm [True]: False
install_dependencies [True]: True
use_async
False
use_async is set to False, your component will not be lazy loaded and fragments will not be created.
Executing: c:\program files\python37\python.exe -m venv venv
'c:\program' is not recognized as an internal or external command,
operable program or batch file.
post_gen_project command failed: c:\program files\python37\python.exe -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 worked around this by running the venv commands and remaining calls in post_gen_project.py manually, but it'd be better if it worked.
Looks like #23 is a similar but much older issue.
hey man, mind sharing with us all the steps you took to make it work? I am trying to do the same but it doesn't really work. if you can share the commands you run and on what path it would be great!
Sure, off the top of my head, I think this is what I did...
- I used a normal cmd.exe window, went to my root dir, and ran
cookiecutter gh:plotly/dash-component-boilerplate - During cookiecutter setup, set
install_dependenciestofalse. - Still in the root dir, run
python -m venv venv. This will set up the virtual environment. (Equivalent of these lines) - run
venv\scripts\activateto activate the virtual environment. Not sure that's part of the script. - change directory to your project dir (created by the cookiecutter). Then run
python -m pip install -r requirements.txt. Note that the virtual environment needs to be activated for this otherwise it'll install the packages globally. This step is here in the normal script. - Install the npm dependencies. In the same folder as step 5, run
npm install --ignore-scripts. This is here in the normal script. - Again from the same directory, build it by running:
npm run build. This step is here in the normal script. - When you edit your component, run
npm run buildagain to rebuild it. - You can run
python usage.pyin the same folder to test it out.
Give that a try. I think at one point I also changed the forward slashes to backslashes in the build script here. Not sure if that's needed now or not.
well, funny enough I already changed my PC username to have no white space, so I no longer have a problem, but I really appreciate you going all the way explaining I am more than sure someone else will need this!