Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find Python executable "python"

When i install iconv with npm got the following error:

[email protected] 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! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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

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

and set up PATH in ~/.bashrc:

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

and done . ~/.bashrc

like image 886
Maxim Yefremov Avatar asked May 09 '14 18:05

Maxim Yefremov


People also ask

Can't find Python executable Python You can set the Python?

To Solve Can't find Python executable “python”, you can set the PYTHON env variable Error You just need to Install Python In Your Windows ( If Not Installed ) and then add python to your PATH variable. Using environment variable. OR You can set npm config set python path and it will also Solve your error.

Where is Python executable located?

Press Start in the lower left corner of your display; press Search; in the search window, press all files and folders; in the top textline that appears, type python.exe; press the Search button. After several minutes, the folder where Python is installed will be listed --- that folder name is the path to Python.

Do we need Python for NPM install?

NPM has a package called windows-build-tools that should automatically install everything you need to get node-gyp working, including the Microsoft build tools, compilers, Python, and everything else required to build native Node modules on Windows.


3 Answers

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  

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

like image 136
Chase Avatar answered Sep 19 '22 19:09

Chase


In your bash session where you're able to just type python and get a valid response, type in which python and note the full path location of the python binary. Take that location and put that into your PYTHONPATH and PATH environment variables, except without the python at the end.

For example, which python gives me:

/usr/local/bin/python

so I would write:

export PYTHONPATH=$PYTHONPATH:/usr/local/bin
export PATH=$PATH:/usr/local/bin

in my ~/.bashrc.

like image 39
huu Avatar answered Sep 19 '22 19:09

huu


There is a simple and safe way Place this into ~/.bashrc or ~/.bash_aliases file:

alias python=python3

After adding the above in the file, run source ~/.bashrc or source ~/.bash_aliases

This solution worked for my Ubuntu see the origin answer here

like image 27
Kelei Ren Avatar answered Sep 18 '22 19:09

Kelei Ren