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

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
> raw-buffer@0.0.19 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: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! raw-buffer@0.0.19 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the raw-buffer@0.0.19 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
                Encountered the same problem, however my system hangs during the visual studio build tools installation(frozen on successfully installed python 2.7 - will it install anything else? it doesn't return me to command prompt). Typed python on command prompt and not working, where should I look for it?
– Kieran F.
                Apr 2, 2019 at 4:41
                @KieranF. In my answer below, i showed how to install build tools with python path and also stated where the python executable file can be found after installing it.
– Israel Obanijesu
                May 26, 2019 at 14:58

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.

    npm --add-python-to-path='true' install --global --production windows-build-tools solved my issue. thanks! – Mücahit Yılmaz Aug 5, 2019 at 10:37 the link to the manual install for the Windows_Build_tools currently returns 404 Not Found. The second tip is recommended, maybe make this the first tip (2nd tip worked for me)? – anneb Nov 10, 2019 at 12:43 Okay, thank you for letting me know. I've updated the link to where you can download Microsoft Build Tools. Also, the second tip is the recommended one, so that is what i expect people to try out first. – Israel Obanijesu Nov 10, 2019 at 22:31 After installing Windows Build Tools from the link, open Visual Studio Installer to check if the installation completed successfully. In my case there was a message saying "Installation finished with warnings". To fix this just press the "Update" button. – eddex Dec 13, 2019 at 9:44 The first one (installing Python 2.7 and pointing npm to it) fixed it for me. Why do we still need Python 2.7 in 2022 for a currently-supported tool like npm... it's kind of ridiculous. – ke4ukz Apr 28, 2022 at 16:33 windows build tools readme says windows build tools comes with the recent versions of npm. I found it in my system and just had to add it to the path as @mdowes has said – msanjay Dec 2, 2021 at 7:19

    Any error that points to a syntax error while executing python code is due to the version of python (python v3 or v2) executable that executes the python script file. In this case specifically, npm is trying to build few node modules because binaries for those modules are not published on internet. Hence when an incorrect version of python compiler (or interpreter as some would say) is loaded and used to build python code, you will see syntax error.

    The fix to such problem is not to uninstall python, because you may need both versions of python for different purposes. Simply add python v2 path before python v3 if you have both or if you do not have python then install python v2 and add the location to environment variable as shown below. Hope this solves the issue.

    Node.js is built with GYP — cross-platform built tool written in Python. Also some other build steps are implemented in Python. So Python is required for building node from source.

    But you also need Python for building native addons.

    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.