吉普 错误!堆栈错误:命令失败:python -c import sys; 打印“%s.%s.%s”% sys.version_info[:3]

Meh*_*hdi 10 python npm vue.js npm-install

我正在尝试在 Vue 项目中进行 npm install,即使我只是运行 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
Run Code Online (Sandbox Code Playgroud)

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

dko*_*kol 16

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

nvm install 14
nvm use 14
Run Code Online (Sandbox Code Playgroud)


小智 5

跑步:npm install --ignore-scripts

  • 答案需要支持信息 您的答案可以通过附加支持信息来改进。请[编辑]添加更多详细信息,例如引文或文档,以便其他人可以确认您的答案是正确的。您可以[在帮助中心](https://stackoverflow.com/help/how-to-answer)找到有关如何编写良好答案的更多信息。 (2认同)