LoginSignup
3
3

More than 5 years have passed since last update.

WindowsのTruffle5/Web3でpythonエラーになる場合は、windows-build-tools

Posted at

Web3 1.0とか、Truffle 5をnpmでインストールする場合、Windowsだとうまくできないことが多い。

たぶんこんなエラーが出てくると思う。Python executableが無いというエラー。

$ npm i web3

> tiny-secp256k1@1.0.1 install \node_modules\tiny-secp256k1
> node-gyp rebuild


\node_modules\tiny-secp256k1>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
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:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:153:21)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd \node_modules\tiny-secp256k1

そういう時は、windows-build-toolsを使うと解消するかもしれません。

Powershellを管理者モードで立ち上げ、以下のコマンドを実行。

npm install --global windows-build-tools

Python2.7のほか、なんかいろいろインストールされます。

web3 0.20.6とか、truffle 4.1.15とかならこの手のエラーにはひっかかりません。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3