Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pythoro opened this issue Jan 27, 2022 · 3 comments
Open

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

pythoro opened this issue Jan 27, 2022 · 3 comments

Comments

@pythoro
Copy link

pythoro commented Jan 27, 2022

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.

@pythoro pythoro changed the title venv creation doesn't work on Windows with spaces in python path venv creation broken on Windows with spaces in python path Jan 27, 2022
@Speodark
Copy link

Speodark commented Feb 2, 2022

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
Copy link
Author

pythoro commented Feb 2, 2022

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.

@Speodark
Copy link

Speodark commented Feb 2, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants