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

[Windows] prisma2 init fails with Error: Can't find Python executable "python", you can set the PYTHON env variable. #550

Closed
janpio opened this issue Sep 13, 2019 · 8 comments · Fixed by prisma/prisma-examples#862
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug.
Milestone

Comments

@janpio
Copy link
Member

janpio commented Sep 13, 2019

prisma2 init for Starter Kit > TypeScript > GraphQL API (+ Auth) > SQLite fails with:

λ prisma2 init p2Win549_3

Preparing your starter kit: GraphQL API (+ Auth)

✔  Downloading the starter kit from GitHub ...
✔  Extracting content to p2Win549_3 ...
⠦  Installing dependencies with: `npm install` ...
4  Preparing your database ...
5  Seeding your database with: `npm run seed` ...
 ERROR  Error during command execution

npm WARN deprecated @types/graphql@14.5.0: This is a stub types definition. graphql provides its own type definitions,
so you do not need this installed.
npm WARN deprecated apollo-upload-server@7.1.0: Please migrate to https://npm.im/graphql-upload (see https://git.io/fAD hl).
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.6/bcrypt_li b-v3.0.6-node-v72-win32-x64-unknown.tar.gz
node-pre-gyp WARN Pre-built binaries not found for bcrypt@3.0.6 and node@12.6.0 (node-v72 ABI, unknown) (falling back t o source compile with node-gyp)
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\ProgramData\nvm\v12.6.0\node_modules\npm\node_modules\node-gyp\lib\ configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\ProgramData\nvm\v12.6.0\node_modules\npm\node_modules\node-gyp\lib\c onfigure.js:509:16)
gyp ERR! stack     at C:\ProgramData\nvm\v12.6.0\node_modules\npm\node_modules\graceful-fs\polyfills.js:282:31
gyp ERR! stack     at FSReqCallback.oncomplete (fs.js:165:21)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\ProgramData\\nvm\\v12.6.0\\node_modules\\npm\\node_modules\ \node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\Users\\Jan\\Documents\\throwaway\\p2Win549 _3\\node_modules\\bcrypt\\lib\\binding\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\\Users\\Jan\\Docu ments\\throwaway\\p2Win549_3\\node_modules\\bcrypt\\lib\\binding" "--napi_version=4" "--node_abi_napi=napi" "--napi_bui ld_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd C:\Users\Jan\Documents\throwaway\p2Win549_3\node_modules\bcrypt
gyp ERR! node -v v12.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\ProgramData\nvm\v12.6.0\node_modu les\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\Jan\Documents\throwaway\p 2Win549_3\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\Jan\Documents \throwaway\p2Win549_3\node_modules\bcrypt\lib\binding --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --no de_napi_label=node-v72' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\Jan\Documents\throwaway\p2Win549_3\node_modules\node- pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:203:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Windows_NT 10.0.17134
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Jan\\Documents\\throwaway\\p2Win549_3\\node _modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\Jan\Documents\throwaway\p2Win549_3\node_modules\bcrypt
node-pre-gyp ERR! node -v v12.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok
npm WARN graphql-shield@5.7.3 requires a peer of graphql-middleware@^2.0.0 || ^3.0.0 but none is installed. You must in stall peer dependencies yourself.
npm WARN graphql-playground-middleware-lambda@1.7.12 requires a peer of aws-lambda@^0.1.2 but none is installed. You mu st install peer dependencies yourself.
npm WARN graphql-subscriptions@0.5.8 requires a peer of graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0 but none is in stalled. You must install peer dependencies yourself.
npm WARN apollo-server-core@1.4.0 requires a peer of graphql@^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 but non e is installed. You must install peer dependencies yourself.
npm WARN apollo-cache-control@0.1.1 requires a peer of graphql@0.10.x - 0.13.x but none is installed. You must install
peer dependencies yourself.
npm WARN apollo-tracing@0.1.4 requires a peer of graphql@0.10.x - 0.13.x but none is installed. You must install peer d ependencies yourself.
npm WARN graphql-extensions@0.0.10 requires a peer of graphql@0.10.x - 0.13.x but none is installed. You must install p eer dependencies yourself.
npm WARN graphql-auth@ No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bcrypt@3.0.6 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@3.0.6 install 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\Jan\AppData\Roaming\npm-cache\_logs\2019-09-13T08_23_08_382Z-debug.log

Versions:

C:\Users\Jan\Documents\throwaway
λ prisma2 -v
prisma2@2.0.0-preview-11, binary version: 408c0c08746064a56c8ba7cb167bad49f1d2c2f7

C:\Users\Jan\Documents\throwaway
λ npm -v
6.9.0

C:\Users\Jan\Documents\throwaway
λ node -v
v12.6.0

Building these node-pre-gyp and similar dependencies on Windows via Python is always a mess unfortunately :(

@janpio janpio added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. labels Sep 13, 2019
@pantharshit00
Copy link
Contributor

An easy fix for this would be to use a pure js implementation of brcypt(https://www.npmjs.com/package/bcryptjs) instead of the implementation that uses C++ bindings(https://www.npmjs.com/package/bcrypt)

We need to change the following dependency: https://github.com/prisma/prisma-examples/blob/ec162bc4d43695147f43234ebe2f16fbba61761f/typescript/graphql-auth/package.json#L10

@janpio
Copy link
Member Author

janpio commented Sep 16, 2019

Installing Python 2.x or Python 3.x manually (e.g. choco install python or choco install python2 if you are using Chocolatey as a program manager) does not solve the problem. (Seems to need Python 2, but even then the build command doesn't just work)

@pantharshit00
Copy link
Contributor

@janpio If we still want to use the native C++ implementation, you should install nodejs build tools for windows

npm install --global --production windows-build-tools

@janpio
Copy link
Member Author

janpio commented Sep 16, 2019

Will try that, just to make sure no other problems are hiding behind the current problem.

@janpio
Copy link
Member Author

janpio commented Sep 17, 2019

Running npm install --global --production windows-build-tools in an Admin (!) PowerShell window indeed let the npm install succeed so this is a valid workaround.

(Unfortunately I hit #531 then, but this is further in the process 🚀 )

@divyenduz
Copy link
Contributor

Prepared a PR with the fixes suggested by @pantharshit00 🤞

Need someone to validate it though, I couldn't reproduce this on my windows instance (cc @janpio 👀)

@pantharshit00
Copy link
Contributor

I can confirm this is fixed now on windows:
image

@divyenduz
Copy link
Contributor

Please try it out with the latest alpha (npm install -g prisma2@alpha).

If the problem persists, please open a new issue and tag me there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants