如何在NPM安装过程中使用不同版本的python? [英] How to use a different version of python during NPM install?
问题描述
Salam(意味着你好):)
我有终端访问VPS运行centos 5.9和默认python 2.4.3安装。我也通过这些命令安装了python 2.7.3(我使用
make altinstall
而不是 make install
)wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar -xf Python-2.7.3.tgz
cd Python-2.7.3
./configure
make
make altinstall
然后我通过这些命令从源代码安装node.js:
python2.7 ./configure
make
make install
问题是,当我使用
npm install
,并尝试安装一个node.js包需要python> 2.4.3我得到这个错误:gyp ERR!配置错误
gyp ERR! stack错误:Python可执行文件python是v2.4.3,不支持gyp。
gyp ERR! stack您可以传递--python开关指向Python> = v2.5.0& < 3.0.0。
gyp ERR! stack failPythonVersion(/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:125:14)
gyp ERR!堆栈在/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:114:9
我应该如何通过--python开关指向Python> = v2.5.0
?解决方案您可以使用
- python
选项,如下所示:npm install --python = python2.7
总是使用:
npm config set python python2.7
Npm会在需要时将此选项传递给node-gyp。
那个在Github上打开了一个问题的人将其包含在文档中,因为有这么多问题;-))
Salam (means Hello) :)
I have terminal access to a VPS running centos 5.9 and default python 2.4.3 installed. I also installed python 2.7.3 via these commands: (I used
make altinstall
instead ofmake install
)wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz tar -xf Python-2.7.3.tgz cd Python-2.7.3 ./configure make make altinstall
then I installed node.js from source via these commands:
python2.7 ./configure make make install
The problem is, when I use
npm install
and try to install a node.js package which requires python > 2.4.3 I get this error:gyp ERR! configure error gyp ERR! stack Error: Python executable "python" is v2.4.3, which is not supported by gyp. gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0. gyp ERR! stack at failPythonVersion (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:125:14) gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:114:9
how should I "pass the --python switch to point to Python >= v2.5.0"?
解决方案You can use
--python
option to npm like so:npm install --python=python2.7
or set it to be used always:
npm config set python python2.7
Npm will in turn pass this option to node-gyp when needed.
(note: I'm the one who opened an issue on Github to have this included in the docs, as there were so many questions about it ;-) )
这篇关于如何在NPM安装过程中使用不同版本的python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!