【问题标题】:gyp ERR! stack Error: Command failed: python -c import sys; print "%s.%s.%s" % sys.version_info[:3]吉普错误!堆栈错误:命令失败:python -c import sys;打印 "%s.%s.%s" % sys.version_info[:3]
【发布时间】:2022-01-11 15:18:38
【问题描述】:

我正在尝试 npm install 在 Vue 项目中,即使我只是运行 vue create (name) 它给了我这个错误:

npm ERR! gyp verb check python checking for Python executable "c:\Python310\python.exe" in the PATH
npm ERR! gyp verb `which` succeeded c:\Python310\python.exe c:\Python310\python.exe
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: c:\Python310\python.exe -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
npm ERR! gyp ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:397:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! gyp ERR! System Windows_NT 10.0.19044
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Upwork\\contact_book\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Upwork\contact_book\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.13.1
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

我在另一台电脑上试过,但它工作正常,我认为是因为我需要安装一些东西(因为电脑是新的)

【问题讨论】:

  • 我假设 gyp 是一个 Node 包(我不是 JS 人)。无论如何,如果是这样,维护者需要更新他们的安装脚本。 print "blah blah blah" 语法来自 Python 2,这是一个旧版本,已经失去支持超过 2 年,并且在此之前很久就被弃用了。正确的 Python 3 语法应该是 print("blah blah blah"),因为 print() 现在是一个函数。
  • 我看到node-gyp 现在使用的是 8.4.1 版,而您似乎使用的是 2018 年发布的 3.8.0 版。您肯定需要升级。
  • 好的,谢谢你,我会尝试这些修复并让你知道@MattDMo
  • 我试过npm i -g node-gyp,但它仍然显示相同的错误node-gyp -v v3.8.0
  • 嘿@MattDMo,我发现 Node 16 现在不支持它,所以我将 Node.js 降级到 v14.18.0 并且它有效,如果你没有告诉我,非常感谢关于版本我不会关注它

标签: python vue.js npm npm-install


【解决方案1】:

正如@MehdiMamas 在 cmets 中指出的那样,将 Node 降级到 v14 应该可以解决问题

nvm install 14
nvm use 14

【讨论】:

    猜你喜欢
    • 2021-12-24
    • 2022-06-14
    • 2015-12-14
    • 2019-10-21
    • 2014-11-02
    • 2016-10-11
    • 2021-08-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多