我正在尝试在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 (这样打印"%s.%s.%s“就不会给出语法错误)。我尝试将settings.json中的python.pythonpath更改为C:/Python27/python.exe,并将vscode中的python解释器更改为Python2.7,但仍然出错。我在windows path变量中有两个指向python3和python2.7的路径。
发布于 2019-12-17 17:17:46
Python您可以通过以下方式之一确定node-gyp应使用哪个
版本:
node-gyp是通过npm调用的,并且您安装了Python的多个版本,则可以将npm的'python‘配置键设置为适当的值:$ npm config set python /path/to/executable/python
PYTHON环境变量设置为Python可执行文件的路径,则将使用该版本(如果它是兼容版本)。NODE_GYP_FORCE_PYTHON环境变量设置为Python可执行文件的路径,则将使用该环境变量,而不使用任何其他已配置或内置的Python搜索路径。如果不是兼容版本,则不会进行进一步搜索。您可以在cmd dispaly环境变量中使用set命令。
PS:在Windows中使用node-gyp需要Visual C++ build tools,Python 2.7 (不支持v3.x.x)和一些配置。你可以的
通过从提升的PowerShell运行
npm install -g windows-build-tools(以管理员身份运行),使用微软的windows-build-tools安装所有必需的工具和配置。
请参见:
set python版本:nodejs/node-gyp: Node.js native addon build tool
环境设置和配置:nodejs-guidelines/windows-environment.md at master · microsoft/nodejs-guidelines
https://stackoverflow.com/questions/57517144
复制相似问题