【发布时间】:2013-12-25 14:13:43
【问题描述】:
我可以通过终端访问运行 centos 5.9 并安装了默认 python 2.4.3 的 VPS。我还通过这些命令安装了 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 并尝试安装需要 python > 2.4.3 的 node.js 包时,我收到此错误:
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
我应该如何“通过 --python 开关指向 Python >= v2.5.0”?
【问题讨论】:
-
我会提议一个 hack。在你的 shell 中给这个 python 版本起别名,然后在你关闭 shell 后,系统应该返回到以前的状态
-
@rafee 太好了,你能解释一下我该怎么做吗?我对 centos 有点陌生!
-
我几乎没用过 CentOS。它应该和任何其他 linux 发行版一样。我说的是临时程序,因为使别名永久化可能会损坏您的系统。所以不应该这样做。
-
@rafee 谢谢,我会检查你的解决方案。
-
alias python=/path/to/python 应该足够好了。但要小心临时更改,永久更改可能会损害您的系统