plotly / dash-component-boilerplate

Get started creating your own Dash components here.
266 stars 182 forks source link

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

Open ghost opened 5 years ago

ghost commented 5 years ago

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.

alexcjohnson commented 5 years ago

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.

mram1000 commented 5 years ago

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)
ghost commented 5 years ago

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

$ npm run build:all

> dash_react_test@0.0.1 build:all C:\Users\my name\...\dash_react_test
> npm run build:js && npm run build:js-dev && npm run build:py

> dash_react_test@0.0.1 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

> dash_react_test@0.0.1 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

> dash_react_test@0.0.1 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! dash_react_test@0.0.1 build:py: `dash-generate-components ./src/lib/components dash_react_test`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the dash_react_test@0.0.1 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! dash_react_test@0.0.1 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 dash_react_test@0.0.1 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 commented 3 years ago

hi, i am also facing this issue. please help

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

my_dash_component@0.0.1 build C:\OtherDocs\my_dash_component npm run build:js && npm run build:py_and_r

my_dash_component@0.0.1 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

my_dash_component@0.0.1 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 commented 3 years ago

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!

AtharvaKatre commented 3 years ago

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?

ryanand26 commented 2 years ago

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.

pythoro commented 2 years ago

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