python.exe语法问题-NPM


问题内容

运行Npm安装时遇到问题。我收到以下错误:

gyp ERR! stack Error: Command failed: C:\Users\userxxx\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:276:12)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at maybeClose (internal/child_process.js:915:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209: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"

我将以下内容添加到我的 Path系统变量 中:

C:\Python27\

在我的 用户Path变量 中,对于Python我有以下内容:

C:\Users\userxxx\AppData\Local\Programs\Python\Python37-32\Scripts\
C:\Users\userxxx\AppData\Local\Programs\Python\Python37-32\
C:\Users\userxxx\AppData\Local\Programs\Python\Python37\Scripts\
C:\Users\userxxx\AppData\Local\Programs\Python\Python37\

不知道这里发生了什么,所以任何帮助表示赞赏!


问题答案:

您尝试运行的命令使用Python 2语法。它与Python 3不兼容,因此,如果尝试使用它, 应该 会出现语法错误。

可以将脚本升级到Python 3(大约已经到了时间),或者修复执行路径,以便可以在过时的Python版本中运行它。