错误:命令失败:C:\Program Files (x86)\Python38-32\python.exe

7

node-gyp rebuild


C:\Users\ASUS-X441M\Desktop\ReadMemoryJS\node_modules\memoryjs>if not defined npm_config_node_gyp (node "D:\Program Files\NodeJS\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "D:\Program Files\NodeJS\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Program Files (x86)\Python38-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:299:12)
gyp ERR! stack     at ChildProcess.emit (events.js:193:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:999:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:266:5)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "D:\\Program Files\\NodeJS\\node.exe" "D:\\Program Files\\NodeJS\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\ASUS-X441M\Desktop\ReadMemoryJS\node_modules\memoryjs
gyp ERR! node -v v11.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN eslint-config-airbnb-base@12.1.0 requires a peer of eslint@^4.9.0 but none is installed. You must install peer dependencies yourself.
npm WARN bl@0.7.0 requires a peer of stream-browserify@* but none is installed. You must install peer dependencies yourself.
npm WARN readmemoryjs@1.0.0 No description
npm WARN readmemoryjs@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! memoryjs@3.2.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the memoryjs@3.2.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我该怎么解决这个问题?我不知道该怎么做。请帮帮我。

我想安装memoryjs。

NodeJS版本:v11.15.0

NPM版本:v6.7.0

操作系统:Windows 10 Enterprise

文本编辑器:VSCode


1
清除npm缓存,然后再尝试安装。 - Punith K
你找到任何解决方案了吗? - Hakan Fıstık
1个回答

4

您正在运行Python 3.8,但该命令在Python 3中无效。它只适用于Python 2。

$ python2 -c 'import sys; print "%s.%s.%s" % sys.version_info[:3];'
2.7.15
$ python3 -c 'import sys; print "%s.%s.%s" % sys.version_info[:3];'
  File "<string>", line 1
    import sys; print "%s.%s.%s" % sys.version_info[:3];
                               ^
SyntaxError: invalid syntax
$ 

Python 2已经老旧且不再受支持,你不应该使用它。我注意到你也在使用Node.js 11,它也不再受支持(并且可能在构建链中的部分使用/需要Python 2)。

所以你至少有两个选择:尝试在PYTHON环境变量中指定Python 2可执行文件,或者升级到受支持的Node.js版本(截至本文撰写时,Node.js 14是最新的LTS版本,并且是一个不错的选择,在所有其他条件相等的情况下)。我建议你更新Node.js而不是使用Python 2,但你当然可以尝试两种方法。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接