plotly / dash-component-boilerplate

Get started creating your own Dash components here.
275 stars 184 forks source link

venv creation broken on Windows with spaces in python path #140

Open pythoro opened 2 years ago

pythoro commented 2 years ago

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)]: test@test.com
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.

Matan-Morduch commented 2 years ago

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!

pythoro commented 2 years ago

Sure, off the top of my head, I think this is what I did...

  1. I used a normal cmd.exe window, went to my root dir, and ran cookiecutter gh:plotly/dash-component-boilerplate
  2. During cookiecutter setup, set install_dependencies to false.
  3. Still in the root dir, run python -m venv venv. This will set up the virtual environment. (Equivalent of these lines)
  4. run venv\scripts\activate to activate the virtual environment. Not sure that's part of the script.
  5. 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.
  6. Install the npm dependencies. In the same folder as step 5, run npm install --ignore-scripts. This is here in the normal script.
  7. Again from the same directory, build it by running: npm run build. This step is here in the normal script.
  8. When you edit your component, run npm run build again to rebuild it.
  9. You can run python usage.py in 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.

Matan-Morduch commented 2 years ago

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!