添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

gyp ERR! stack Error: Command failed: python -c import sys; print "%s.%s.%s" % sys.version_info[:3]

Ask Question

I'm trying to npm install in a Vue project, and even if I just ran vue create (name) it gives me this err:

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

I tried it in another PC but it is working fine, I think it is because I need to install something (since the PC is new)

I'm assuming gyp is a Node package (I'm not a JS guy). At any rate, if it is, the maintainers need to update their install script. The print "blah blah blah" syntax is from Python 2, an old version that has been out of support for over 2 years and deprecated long before that. The correct Python 3 syntax would be print("blah blah blah") because print() is a function now. – MattDMo Jan 11, 2022 at 15:22 I see node-gyp is now on version 8.4.1, while you seem to be using version 3.8.0, which was released in 2018. You definitely need to upgrade. – MattDMo Jan 11, 2022 at 15:28 I tried npm i -g node-gyp but It still shows up the same error with the same node-gyp -v v3.8.0 – Mehdi Mamas Jan 11, 2022 at 16:02 Hey @MattDMo, I found out that Node 16 doesn't support it right now, so I downgraded Node.js to v14.18.0 and it worked, thanks a lot if you didn't tell me about the version I wasn't going to pay attention to it – Mehdi Mamas Jan 11, 2022 at 16:30 @MehdiMamas downgrading Node to v14 indeed works, thanks!. You could answer your own question and mark it as correct, so everyone who stumbled into this could see the solution – dkol Feb 2, 2022 at 8:33

As @MehdiMamas pointed out in the comments, downgrading Node to v14 should solve the problem

nvm install 14
nvm use 14

Another solution, which worked for me (and in my opinion the better one), is to update the used packages inside the package.json. I find the package/tool npm-check-updates pretty handy for that.

Sometimes you just want to use the old version, updating everything will cause a lot of errors (sometimes) – Mehdi Mamas Aug 17, 2022 at 13:55

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.