0

So I ran npm install --global windows-build-tools thing as an administrator and it said that I have successfully installed python 2.7.

But then when I tried electron-rebuild -f -w sqlite3 after npm i sqlite3 it gives me this error.

× Rebuild Failed

An unhandled error occurred inside electron-rebuild

gyp ERR! configure error

gyp ERR! stack Error: Command failed: C:\Users\newub\AppData\Local\Programs\Python\Python37\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];

gyp ERR! stack File "", line 1

gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];

gyp ERR! stack ^

gyp ERR! stack SyntaxError: invalid syntax

hiitiger
  • 545
  • 4
  • 13
ima_prog
  • 119
  • 1
  • 9

2 Answers2

1

According to the message you are using Python 3.7 but those code need Python 2.7 to run.

You can identify which Python version node-gyp should use in one of the following ways:

  1. If node-gyp is called by way of npm, and you have multiple versions of Python installed, then you can set npm's 'python' config key to the appropriate value:

$ npm config set python /path/to/executable/python 
  1. If the PYTHON environment variable is set to the path of a Python executable, then that version will be used, if it is a compatible version.

  2. If the NODE_GYP_FORCE_PYTHON environment variable is set to the path of a Python executable, it will be used instead of any of the other configured or builtin Python search paths. If it's not a compatible version, no further searching will be done.

You can use set command in cmd dispaly environment variable.

PS: Using node-gyp in Windows needs Visual C++ build tools, Python 2.7 (v3.x.x is not supported) and some config. You can

Install all the required tools and configurations using Microsoft's windows-build-tools by running npm install -g windows-build-tools from an elevated PowerShell (run as Administrator).

See:

set python version: nodejs/node-gyp: Node.js native addon build tool

Environment setup and configuration: nodejs-guidelines/windows-environment.md at master · microsoft/nodejs-guidelines

feng zhang
  • 1,193
  • 7
  • 8
0

It shows node-gyp is using python 3 in your system.

But node-gyp needs python 2.

You can add python 2 Path in your $Path environment variable before python 3 Path.

type which python in cmd make sure it's python 2.

hiitiger
  • 545
  • 4
  • 13