我正在尝试在 Azure 区块链服务上部署智能合约。我创建了一个区块链联盟并将其连接到 Azure 区块链服务的 VSCode 扩展。但是,当我尝试从 Command Palette 运行 New Solidity Project 命令时,我得到以下信息:
[Execute command] × Setting up box
[Execute command] Error: Command failed: npm install
npm WARN deprecated fs-promise@2.0.3: Use mz or fs-extra^3.0 with Promise
Support
npm WARN deprecated tar.gz@1.0.7: ⚠️ WARNING ⚠️ tar.gz module has been
deprecated and your application is vulnerable. Please use tar module
instead: https://npmjs.com/tar
gyp ERR! configure error
gyp ERR! stack Error: Command failed:
C:\Users\manul\AppData\Local\Programs\Python\Python37-32\python.EXE -c
import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at maybeClose (internal/child_process.js:962:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit
(internal/child_process.js:251:5)
gyp ERR! System Windows_NT 10.0.17134
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
d:\Coding\VSProjects\SecureElectronicVoting\.vscode\node_modules\scrypt
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9
(node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for
fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current:
{"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt@6.0.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the scrypt@6.0.3 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\manul\AppData\Roaming\npm-cache\_logs\2019-08-
15T22_18_54_838Z-debug.log
at checkExecSyncError (child_process.js:616:11)
at execSync (child_process.js:653:13)
at Object.installBoxDependencies (C:\Users\manul\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-box\lib\utils\unbox.js:118:1)
at Object.setUpBox (C:\Users\manul\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-box\lib\utils\index.js:62:1)
at Object.unbox (C:\Users\manul\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-box\box.js:58:1)
[Execute command] Truffle v5.0.32 (core: 5.0.32)
Node v10.15.0
[Execute command] Finished running command
我知道这是因为该命令尝试使用 Python3 而它应该使用 Python2.7(因此 print "%s.%s.%s" 不会给出语法错误)。我尝试将 settings.json 中的 python.pythonpath 更改为 C:/Python27/python.exe 并将 vscode 中的 python 解释器更改为 Python2.7,但它仍然给出错误。我的 Windows 路径变量中有两个到 python3 和 python2.7 的路径。