Skip to content

print() is a function in Python 3 #1965

@mcandre

Description

@mcandre

On my machine, the python binary points to Python v3.7.

$ cat .python-version 
3.7.4

$ pyenv versions
  system
  2.7.13
  2.7.15
  3.4.3
  3.7.0
* 3.7.4

$ python --version
Python 3.7.4

$ npm config get python
/Users/tkmamhf/.pyenv/shims/python

However, when I try to npm install a package like appmetrics-prometheus which depends on node-gyp, then node-gyp sends Python 2 style code to query the Python version, which fails:

$ npm install

gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /Users/tkmamhf/.pyenv/shims/python -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:189:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:970:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:389:11)
gyp ERR! stack     at Socket.emit (events.js:189:13)
gyp ERR! stack     at Pipe._handle.close (net.js:597:12)

I forcibly reconfigured my NPM python path with npm config set python python3.7 and get the same error.

Please make sure to wrap print arguments in safety parentheses, so that this query for Python versions can be supplied to different Python versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Node Sass --> Dart Sasshttps://github.com/sass/node-sass/issues/2952

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions