56.ERR! configure error gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
Node.js 在安装模块的时候报错,缺少python环境。
ERR! configure error gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
错误信息如下:
| 123456789101112 | D:\node_modules\selenium-webdriver\node_modules\ws\node_modules\utf-8-validate>node "D:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild``ERR! configure error``gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.``gyp ERR! stack at failNoPython (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:103:14)``gyp ERR! stack at D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11``gyp ERR! stack at Object.oncomplete (fs.js:107:15)``gyp ERR! System Windows_NT 6.2.9200``gyp ERR! command "node" "D:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"``gyp ERR! cwd D:\node_modules\selenium-webdriver\node_modules\ws\node_modules\utf-8-validate``gyp ERR! node -v v0.10.29``gyp ERR! node-gyp -v v0.13.1``gyp ERR! not ok |
|---|
原因看node-gyp的安装需求,github.com/nodejs/node…, 部分剪切如下,可以请求的看到需要安装python2.7(其实2.6也行)python3不行
You can install with
npm:$ npm install -g node-gypYou will also need to install:
On Unix:
python(v2.7recommended,v3.x.xis not supported)make- A proper C/C++ compiler toolchain, like GCC
On Mac OS X:
- You also need to install the
Command Line Toolsvia Xcode. You can find this under the menuXcode -> Preferences -> Downloads- This step will install
gccand the related toolchain containingmakepython(v2.7recommended,v3.x.xis not supported) (already installed on Mac OS X)- Xcode
On Windows:
- For 64-bit builds of node and native modules you will also need the Windows 7 64-bit SDK
- You may need to run one of the following commands if your build complains about WindowsSDKDir not being set, and you are sure you have already installed the SDK:
- Microsoft Visual Studio C++ 2013 for Windows Desktop (Express version works well)
- Microsoft Visual Studio C++ 2013 (Express version works well)
- If the install fails, try uninstalling any C++ 2010 x64&x86 Redistributable that you have installed first
- If you get errors that the 64-bit compilers are not installed you may also need thecompiler update for the Windows SDK 7.1
- Make sure that you have a PYTHON environment variable, and it is set to drive:\path\to\python.exe not to a folder
- Python (
v2.7.3recommended,v3.x.xis not supported)- Windows XP/Vista/7:
- Windows 7/8:
- All Windows Versions
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x86 call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64If you have multiple Python versions installed, you can identify which Python version
node-gypuses by setting the '--python' variable:$ node-gyp --python /path/to/python2.7If
node-gypis called by way ofnpmand 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/python2.7Note that OS X is just a flavour of Unix and so needs
python,make, and C/C++. An easy way to obtain these is to install XCode from Apple, and then use it to install the command line tools (under Preferences -> Downloads).