Node.js 在安装模块的时候报错,缺少python环境。

ERR! configure error gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

错误信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
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的安装需求,https://github.com/nodejs/node-gyp, 部分剪切如下,可以请求的看到需要安装python2.7(其实2.6也行)python3不行

You can install with npm:

$ npm install -g node-gyp

You will also need to install:

  • On Unix:

    • python (v2.7 recommended, v3.x.x is not supported)

    • make

    • A proper C/C++ compiler toolchain, like GCC

  • On Mac OS X:

    • You also need to install the Command Line Tools via Xcode. You can find this under the menu Xcode -> Preferences -> Downloads

    • This step will install gcc and the related toolchain containing make

    • python (v2.7 recommended, v3.x.x is 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.3 recommended, v3.x.x is 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 /x64

If you have multiple Python versions installed, you can identify which Python version node-gyp uses by setting the '--python' variable:

$ node-gyp --python /path/to/python2.7

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/python2.7

Note that OS X is just a flavour of Unix and so needs pythonmake, 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).

所以下载安装Python2.7就行了,记得配环境变量。

最新文章

  1. amCharts图表中的JavaScript中文注释引起的浏览器兼容性问题
  2. Android深度探索--HAL与驱动开发----第五章读书笔记
  3. OpenGL学习笔记1——第一个程序
  4. 驳 GarbageMan 的《一个超复杂的简介递归》——对延迟计算的实验和思考
  5. 怎样用ZBrush中的shadowbox创建物体
  6. UVa11082 Matrix Decompressing(最小费用最大流)
  7. 如何实现ZBrush中的Alt和Shift键的快速运用
  8. Orchard源码分析(1):插件式的支持——模块和主题
  9. RotatingDoughnut
  10. careercup-树与图 4.7
  11. MySQL 触发器的定义
  12. 从汇编看c++成员函数指针(三)
  13. 存储、读取——Android应用程序内置的文件夹
  14. ios打开系统自带APP
  15. Spring中AOP简介与切面编程的使用
  16. Jni中C++和Java的参数传递(转)
  17. linux下安装ffmpeg
  18. Python 经典面试题汇总之数据库篇
  19. Beta 冲刺(7/7)
  20. PADS Layout VX.2.3 设置测量精度

热门文章

  1. linux中不同颜色的文件代表什么不同的类型
  2. Webkit 的麻烦和解决
  3. canvas为什么你指定一个比较小的宽高,但它实际占位却很多?
  4. http://www.open-open.com/lib/tag/ReactiveCocoa
  5. 洛谷 P2542 [AHOI2005]航线规划 树链剖分_线段树_时光倒流_离线
  6. HDU-1023 Train Problem II 卡特兰数(结合高精度乘除)
  7. Java 异常的捕获与处理详解 (一)
  8. POJ——T 2449 Remmarguts' Date
  9. 仿分词统计的MapReduce 程序。
  10. ArcGIS api for javascript——地图配置-增加一个调试控制台<