Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After `npm install` an error about a syntax error in python appears?

I am trying to install the necessary dependencies for Exokit, but I am getting an error relating to a Python syntax error.

This is for a something new I wanted to try involving VR in the browser. I've recloned the repository from their github and downloaded straight from their website. I followed the instructions given to a T (there was only 4 of them lol).

I have not yet touched the code and this is the error that I am getting.  Austin@DESKTOP-UD2R1O4 MINGW64 ~/exokit (master) $ npm install  > [email protected] install C:\Users\Austin\exokit\node_modules\raw-buffer > node-gyp rebuild   C:\Users\Austin\exokit\node_modules\raw-buffer>if not defined  npm_config_node_gyp (node "C:\Program  Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-  bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild ) gyp ERR! configure error gyp ERR! stack Error: Command failed: C:\Users\Austin\Anaconda3\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:276:12) gyp ERR! stack     at emitTwo (events.js:126:13) gyp ERR! stack     at ChildProcess.emit (events.js:214:7) gyp ERR! stack     at maybeClose (internal/child_process.js:915:16) gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) gyp ERR! System Windows_NT 10.0.17134 gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\Austin\exokit\node_modules\raw-buffer gyp ERR! node -v v8.12.0 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})  npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] install: `node-gyp rebuild` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.  npm ERR! A complete log of this run can be found in: npm ERR!     C:\Users\Austin\AppData\Roaming\npm-cache\_logs\2019-01-06T06_55_37_752Z-debug.log 
like image 972
Revircs Avatar asked Jan 06 '19 07:01

Revircs


People also ask

How do you fix a syntax error in Python?

You can clear up this invalid syntax in Python by switching out the semicolon for a colon. Here, once again, the error message is very helpful in telling you exactly what is wrong with the line.

Why is it showing syntax error in Python?

Syntax errors are produced by Python when it is translating the source code into byte code. They usually indicate that there is something wrong with the syntax of the program. Example: Omitting the colon at the end of a def statement yields the somewhat redundant message SyntaxError: invalid syntax.

Why npm install showing error?

The npm ERR! code 1 error usually occurs when you run the npm install command. This cause of this error is that one of the dependencies you define in your package. json file fails to be installed properly on your computer.


Video Answer


2 Answers

Try this in cmd administrator (or Windows Powershell Administrator if cmd freezes)

npm install --global windows-build-tools

like image 143
Kalpesh Kashyap Avatar answered Sep 19 '22 14:09

Kalpesh Kashyap


In case the answer(s) provided doesn't work for you, here are some tips you can follow in order to mitigate related problems for windows OS.

NOTE: If you already tried installing the build tools via npm command with no success, it is probably a good idea to delete everything before applying any of the tips below.

You can find the build tools here and just delete the folders (but I don't know if they are installed somewhere else):

  • C:\Users\'yourUser'\.windows-build-tools\
  • C:\Users\'yourUser'\AppData\Roaming\npm\node_modules\windows-build-tools

After ensuring that the folders specified above are deleted, then you can try applying any of the following tips.

First Tip:

  • Run CMD or PowerShell as Administrator
  • Install node-gyp using the following command: npm install -g node-gyp
  • Download and install windows build tools manually from this link: Windows_Build_tools
  • Download and install Python 2.7
  • Register Microsoft Visual Studio version to npm using the following command: npm config set msvs_version <your msvs_version e.g. 2017>
  • Register the path of python executable file to npm using the following command: npm config set python <the path to python executable file>

Second Tip (RECOMMENDED)

  • Run CMD or PowerShell as Administrator
  • Install windows-build-tools with the python-path directly using the following command: npm --add-python-to-path='true' install --global --production windows-build-tools
  • You can run the following command: npm config set python <the path to python executable file>, in order to be sure that npm is pointing to the correct path of python executable file.
    In order to use this command, you can find the python path here (i.e. after running the command in the previous step): C:\Users\<your_user_name>\.windows-build-tools\python27

More information or description about node-gyp can be found here: node-gyp

More information about possible windows build tools issues can be found in the following links: https://github.com/felixrieseberg/windows-build-tools/issues/47
https://github.com/felixrieseberg/windows-build-tools/issues/56

Additional Note: Some people tend to have spaces in their project path names whereas, some tools don't handle spaces in path names well. You can get more info here: https://github.com/nodejs/node-gyp/issues/809

Hope this solves your problem.

like image 33
Israel Obanijesu Avatar answered Sep 20 '22 14:09

Israel Obanijesu