如何修复Windows 10上的电子sqlite3重建错误(语法错误) [英] How to fix electron sqlite3 rebuild error ( Syntax error) on windows 10
问题描述
所以我以管理员身份运行npm install --global windows-build-tools
,它说我已经成功安装了python 2.7.
So I ran npm install --global windows-build-tools
thing as an administrator and it said that I have successfully installed python 2.7.
但是当我在npm i sqlite3
之后尝试electron-rebuild -f -w sqlite3
时,它给了我这个错误.
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错误!配置错误
gyp ERR! configure error
gyp错误!堆栈错误:命令失败: C:\ Users \ newub \ AppData \ Local \ Programs \ Python \ Python37 \ python.EXE -c 进口系统;打印%s.%s.%s"%sys.version_info [:3];
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错误!堆叠文件",第1行
gyp ERR! stack File "", line 1
gyp错误!堆栈导入系统;打印%s.%s.%s"% sys.version_info [:3];
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp错误!堆叠^
gyp ERR! stack ^
gyp错误!堆栈SyntaxError:语法无效
gyp ERR! stack SyntaxError: invalid syntax
推荐答案
根据您正在使用Python 3.7
的消息,但是这些代码需要Python 2.7
才能运行.
According to the message you are using Python 3.7
but those code need Python 2.7
to run.
您可以通过以下方式之一确定应使用哪个Python版本
node-gyp
:
- 如果通过
npm
,和调用node-gyp
,则安装了多个版本的Python,则可以设置npm
的"python"配置 设置为适当值的键:
- If
node-gyp
is called by way ofnpm
, and you have multiple versions of Python installed, then you can setnpm
's 'python' config key to the appropriate value:
$ npm config set python /path/to/executable/python
-
如果将
PYTHON
环境变量设置为Python可执行文件的路径,则将使用该版本(如果兼容) 版本.
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.
如果将NODE_GYP_FORCE_PYTHON
环境变量设置为Python可执行文件的路径,则将使用它代替任何
其他已配置或内置的Python搜索路径.如果不是
兼容版本,将不再进行搜索.
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.
您可以在cmd分配环境变量中使用set
命令.
You can use set
command in cmd dispaly environment variable.
PS:在Windows中使用node-gyp
需要Visual C++ build tools
,Python 2.7
(不支持v3.x.x
)和一些配置.您可以
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
使用Microsoft的工具安装所有必需的工具和配置 通过从中运行
npm install -g windows-build-tools
来运行Windows-build-tools 提升的PowerShell(以管理员身份运行).
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).
请参阅:
设置python版本: nodejs/node-gyp:Node.js本机插件建造 工具
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
这篇关于如何修复Windows 10上的电子sqlite3重建错误(语法错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!