Python syntax error when installing npm component

Viewed 2143

I am trying to install the following vue component via npm:

https://github.com/xwpongithub/vue-range-slider

I am installing it as:

npm install vue-range-component --save

However, I am getting the following errors in the console:

> fsevents@1.2.11 install /Users/jovan/Desktop/work/projects/topgraphs/node_modules/fsevents
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /Users/jovan/anaconda3/bin/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:200:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
gyp ERR! stack     at Socket.<anonymous> (internal/child_process.js:430:11)
gyp ERR! stack     at Socket.emit (events.js:200:13)
gyp ERR! stack     at Pipe.<anonymous> (net.js:586:12)
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/usr/local/Cellar/node/12.3.1/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/jovan/Desktop/work/projects/topgraphs/node_modules/fsevents
gyp ERR! node -v v12.3.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ vue-range-component@1.0.3

So, apparently, the component was installed, but there is some sort of syntax error in Python? Searching the internet for a solution, I have only found some references to different Python versions, but there is no mention of a version in the entire error output above. I am using Python 3.7.

2 Answers

Yes, the Python code given is only valid with python versions before python3.

import sys; print "%s.%s.%s" % sys.version_info[:3];

In python3 the print statement was made a function, so the parenthesis can't be left out. The package should be updated to use:

import sys; print("%s.%s.%s" % sys.version_info[:3]);

.. instead.

The syntax

print "string"

is not valid in Python 3+.

You have Python 3 but the library uses Python 2.7, so install that Python 2.7.

Related