dash-component-boilerplate icon indicating copy to clipboard operation
dash-component-boilerplate copied to clipboard

dash-generate-components doesn't allow whitespaces in path

Open ghost opened this issue 6 years ago • 8 comments

Hi! Thank you for this neat boilerplate that brings me into the interplay of React and dash. After all set up I tried to generate necessary python classes by running npm run build:py. There is an error with Cannot find module <part of my project path>. I guess the reason is that there is a whitespace in my working path and the dash-generate-componentsmodule (in Scripts) cannot recognize the complete path. Sorry I can't change it because it is set by our IT, but I think there could be a way to make this compatible.

ghost avatar May 02 '19 12:05 ghost

Seems like a reasonable guess as to the root cause and we should be able to find a solution. Can you post the full error, with whatever traceback it includes? You can redact or mangle confidential info, but I'd like to see where exactly the code is failing and what part of your path the space is in.

alexcjohnson avatar May 02 '19 16:05 alexcjohnson

I got similar error - looks like due to whitespace in path to python interpreter. How can I fix this pls?

Executing: c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\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 (x86)\microsoft visual studio\shared\anaconda3_64\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)

mram1000 avatar May 20 '19 14:05 mram1000

Hi @alexcjohnson sorry for the late reply! Finally got some free time for personal github 🤣 Here is the complete error:

$ npm run build:all

> [email protected] build:all C:\Users\my name\...\dash_react_test
> npm run build:js && npm run build:js-dev && npm run build:py


> [email protected] build:js C:\Users\my name\...\dash_react_test
> webpack --mode production

Hash: 3b3509a5cd97b02e3d20
Version: webpack 4.30.0
Time: 2306ms
Built at: 2019-05-24 10:53:41
                 Asset      Size  Chunks             Chunk Names
dash_react_test.min.js  3.37 KiB       0  [emitted]  main
Entrypoint main = dash_react_test.min.js
[0] ./src/lib/index.js 443 bytes {0} [built]
[2] external "React" 42 bytes {0} [built]
    + 4 hidden modules

> [email protected] build:js-dev C:\Users\my name\...\dash_react_test
> webpack --mode development

Hash: ...
Version: webpack 4.30.0
Time: 2306ms
Built at: 2019-05-24 10:53:49
                 Asset     Size  Chunks             Chunk Names
dash_react_test.dev.js  113 KiB    main  [emitted]  main
Entrypoint main = dash_react_test.dev.js
[./src/lib/index.js] 443 bytes {main} [built]
[react] external "React" 42 bytes {main} [built]
    + 8 hidden modules

> [email protected] build:py C:\Users\my name\...\dash_react_test
> dash-generate-components ./src/lib/components dash_react_test

internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'C:\Users\my'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

Error generating metadata in dash_react_test (status=1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build:py: `dash-generate-components ./src/lib/components dash_react_test`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build:py script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\my name\AppData\Roaming\npm-cache\_logs\2019-05-24T08_53_57_584Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build:all: `npm run build:js && npm run build:js-dev && npm run build:py`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build:all script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\my name\AppData\Roaming\npm-cache\_logs\2019-05-24T08_53_57_625Z-debug.log

Thank you very much! Just an update: I tested it directly in a folder under C:\ and it worked fine. :)

ghost avatar May 24 '19 08:05 ghost

hi, i am also facing this issue. please help

(venv) (mydashenv) C:\OtherDocs\my_dash_component>npm run build

[email protected] build C:\OtherDocs\my_dash_component npm run build:js && npm run build:py_and_r

[email protected] build:js C:\OtherDocs\my_dash_component webpack --mode production

Hash: d9dbad6cc586fc09249e Version: webpack 4.36.1 Time: 777ms Built at: 08/04/2020 17:11:01 Asset Size Chunks Chunk Names my_dash_component.min.js 3.18 KiB 0 [emitted] main my_dash_component.min.js.map 7.61 KiB 0 [emitted] main Entrypoint main = my_dash_component.min.js my_dash_component.min.js.map [0] external "PropTypes" 42 bytes {0} [built] [1] external "React" 42 bytes {0} [built] [2] ./src/lib/index.js + 1 modules 5.15 KiB {0} [built] | ./src/lib/index.js 143 bytes [built] | + 1 hidden module

[email protected] build:py_and_r C:\OtherDocs\my_dash_component dash-generate-components ./src/lib/components my_dash_component

internal/modules/cjs/loader.js:968 throw err; ^

Error: Cannot find module 'c:\users\rashida' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15) at Function.Module._load (internal/modules/cjs/loader.js:841:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: []

ghost avatar Aug 04 '20 16:08 ghost

Just want to highlight that the above issue has been fixed for me. I ended up using Git Bash instead of Command line to run the npm build and it worked fine!

ghost avatar Aug 06 '20 11:08 ghost

Hi, I was trying out this library for the first time and ran into this same issue. Is there any update/fix on this? I don't want to switch to Git Bash as suggested by the previous user, should I just avoid having white spaces in my path?

AtharvaKatre avatar Jul 07 '21 09:07 AtharvaKatre

I'm new to python but in case it helps I think the issue is with the use of shlex.split in post_gen_project.py.

If you install manually (choose install_dependancies: false and follow instructions in readme.md) then it should work.

If you wanted to amend the script then:

  1. When you run the cookiecutter command for the first time it will download the dash-component-boilerplate script.
  2. Go to that location. Mine was C:\Users\username.cookiecutters\dash-component-boilerplate
  3. Open /hooks/post_gen_project.py
  4. Change subprocess.call to use 'cmd' not 'line'
  5. Wrap the path in double quotes: venv = '"{}" -m venv venv'.format(sys.executable)
  6. Run the cookiecutter command and enter 'no' when asked if it should re-download the template
  7. Let us know here if that works...

This got me past that particular error message.

ryanand26 avatar Nov 17 '21 16:11 ryanand26

I had the same issue. I moved the package to a path without spaces to work around it.

pythoro avatar Jan 27 '22 02:01 pythoro