提问者:小点点

无法运行python cmd命令。 引发语法错误


我使用node-gyp configure是因为前端项目需要这样做。 我使用的是Windows10,整个过程分崩离析。

以下是错误消息:

$ node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@10.20.1 | win32 | x64
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\xetra11\AppData\Local\Programs\Python\Python37\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:294:12)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:982:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
gyp ERR! System Windows_NT 10.0.18363

我试图重现python的问题:

$ python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
  File "<string>", line 1
    import
         ^
SyntaxError: invalid syntax
Unable to initialize device PRN

Python版本是3.7.1

知道怎么绕过这个吗? 我需要降级我的python版本吗?


共1个答案

匿名用户

python版本的3.x中需要打印(“text”,or_variable)。