找不到 Python 可执行文件“python" [英] Can't find Python executable "python"

查看:108
本文介绍了找不到 Python 可执行文件“python"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我用 npm 安装 iconv 时出现以下错误:

When i install iconv with npm got the following error:

iconv@2.1.0 安装/root/Dropbox/nodeApps/nodeApp/node_modules/iconv节点gyp重建

iconv@2.1.0 install /root/Dropbox/nodeApps/nodeApp/node_modules/iconv node-gyp rebuild

gyp 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 (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:103:14)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:42:11
gyp ERR! stack     at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:43:25)
gyp ERR! stack     at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:46:29)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/which.js:57:16
gyp ERR! stack     at Object.oncomplete (fs.js:107:15)
gyp ERR! System Linux 3.8.0-19-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/Dropbox/nodeApps/nodeApp/node_modules/iconv
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok 

npm ERR! iconv@2.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the iconv@2.1.0 install script.
npm ERR! This is most likely a problem with the iconv package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls iconv
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.8.0-19-generic
npm ERR! command "node" "/usr/local/bin/npm" "i"
npm ERR! cwd /root/Dropbox/nodeApps/nodeApp
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.10
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /root/Dropbox/nodeApps/nodeApp/npm-debug.log
npm ERR! not ok code 0

虽然我安装了 python 并且可以从控制台运行它:

although I installed python and can run it from console:

# python
Python 2.7.3 (default, May  9 2014, 12:18:32) 
[GCC 4.8.2] on linux2

并在~/.bashrc中设置PATH:

export PYTHONPATH=$PYTHONPATH:/Python-2.7.3
export PATH=$PATH:/Python-2.7.3

并完成<代码>.~/.bashrc

推荐答案

对于在 Ubuntu 16.04 上遇到此问题的任何人...
node-gyp 不能使用 Python 3.5.X,这似乎是 16.04 附带的默认值.我在某处读到 16.04 也应该随 Python2 一起提供,但我在安装时找不到它.

For anyone encountering this issue on Ubuntu 16.04...
node-gyp can't use Python 3.5.X which seems to the be the default that ships with 16.04. I read somewhere that 16.04 was supposed to ship with Python2 as well but I can't find it on my install.

我通过以下方式解决了上述问题:

I fixed the above issue by:

apt-get update     
apt-get install python2.7    
ln -s /usr/bin/python2.7 /usr/bin/python 

现在当 node-gyp 去寻找 python 时,它会命中你的 Python2.7 安装并正确加载.

Now when node-gyp goes looking for python it will hit your Python2.7 install and load correctly.

这篇关于找不到 Python 可执行文件“python"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆