New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find Python executable "python" after installing #56

Closed
mikew opened this Issue Apr 23, 2017 · 34 comments

Comments

Projects
None yet
@mikew
Copy link

mikew commented Apr 23, 2017

node-gyp is failing because it can't find python. windows-build-tools did its thing and python is installed:

$ $(npm config get python)
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
$ npm --version
4.5.0
$ node --version
v7.9.0

Here's the output from node-gyp:

+ node_modules/.bin/electron-rebuild --arch x64 -f -p -w serialport -m electron-app
× Rebuild Failed
An unhandled error occurred inside electron-rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.0
gyp info using node@7.9.0 | win32 | x64
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 PythonFinder.failNoPython (C:\Users\mike\Work\dronefuse-client\node_modules\node-gyp\lib\configure.js:482:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Users\mike\Work\dronefuse-client\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at C:\Users\mike\Work\dronefuse-client\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:114:15)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\mike\\Work\\dronefuse-client\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=1.4.13" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=serialport" "--module_path=C:\\Users\\mike\\Work\\dronefuse-client\\electron-app\\node_modules\\serialport\\build\\Release" "--host=https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7"
gyp ERR! cwd C:\Users\mike\Work\dronefuse-client\electron-app\node_modules\serialport
gyp ERR! node -v v7.9.0
gyp ERR! node-gyp -v v3.6.0
gyp ERR! not ok
@mikew

This comment has been minimized.

Copy link

mikew commented Apr 23, 2017

It's as if npm isn't even checking the value of python that is set, because this invocation works:

PATH="$(dirname $(npm config get python)):$PATH" node_modules/.bin/electron-rebuild --arch x64 -f -p -w serialport -m electron-app
@galkowskit

This comment has been minimized.

Copy link

galkowskit commented May 12, 2017

Same issue here.

@choucry13

This comment has been minimized.

Copy link

choucry13 commented May 17, 2017

+1

@garolion

This comment has been minimized.

Copy link

garolion commented May 26, 2017

solution: nfroidure/ttf2woff2#28
npm install --global --production windows-build-tools

@felixrieseberg

This comment has been minimized.

Copy link
Owner

felixrieseberg commented Jun 8, 2017

Hm, seems like this is more with electron-rebuild than with npm. I assume the real solution here is to also ensure that python is globally accessible, which would require checking if it isn't already.

I'd gladly accept a PR for that, I'm not sure when I'll get to it.

@ArminMa

This comment has been minimized.

Copy link

ArminMa commented Jun 15, 2017

https://github.com/felixrieseberg/windows-build-tools/issues/33

npm --add-python-to-path='true' --debug install --global windows-build-tools

@jeanru

This comment has been minimized.

Copy link

jeanru commented Sep 6, 2017

npm config set python "c:\Python\27\python.exe"

@hemano hemano referenced this issue Oct 12, 2017

Closed

error #9183

@dougbacelar

This comment has been minimized.

Copy link

dougbacelar commented Oct 19, 2017

@ArminMa solution solved my issue! Had to run the CLI as administrator.

@harrodevos

This comment has been minimized.

Copy link

harrodevos commented Nov 17, 2017

@ArminMa's solution worked for me too!

I first had Python version 3.6 for Windows installed on a Windows Server 2016 machine. I used the windows executable installation.

This was required in order to install the web3 package.

But no matter how I set path and environment variables, during the npm install of web3 it kept complaining it couldn't find the python executable. Typing python in the command prompt worked fine.

I suspect it has to do with version/compatibility issues between web3 and python. After uninstalling the 3.6 version of python and installing 2.7 using the npm command ArminMa suggested it all works!

I did update my environment variables (PYTHON and PATH) to the 2.7 executable.

@thuyvtgl

This comment has been minimized.

Copy link

thuyvtgl commented Dec 6, 2017

Thank guys,
especially thank @ArminMa, you solved my issue.

@dhanabalcbt

This comment has been minimized.

Copy link

dhanabalcbt commented Dec 30, 2017

thanks arima

@Philip-Nunoo

This comment has been minimized.

Copy link

Philip-Nunoo commented Jan 19, 2018

Thanks @ArminMa

@mapplics

This comment has been minimized.

Copy link

mapplics commented Jan 26, 2018

thanks @aminma you save my day!

@bibhuticoder

This comment has been minimized.

Copy link

bibhuticoder commented Jan 31, 2018

Installing python 2.* worked for me.

@hallss93

This comment has been minimized.

Copy link

hallss93 commented Feb 8, 2018

@garolion obrigado. Estive com esse problema por um bom tempo. Consegui corrigir com isso! 🥇

@SatishMHiremath

This comment has been minimized.

Copy link

SatishMHiremath commented Feb 17, 2018

I have faced and fixed this issue relates node-sass and python error.Try installing latest angular cli command with the steps below

Set the system variable path as well:
C:\Users\windowsusername\AppData\Roaming\npm

C:\Users\windowsusername\AppData\Roaming\npm\node_modules@angular\cli\bin;

C:\Program Files\nodejs;

Then start using angular cli command prompt using:
angular client project folder path>npm install -g @angular/cli@latest

angular client project folder path>npm install -g node-gyp

@walalm

This comment has been minimized.

Copy link

walalm commented Jun 5, 2018

Executing: npm install --global --production windows-build-tools and then
executing npm rebuild did the trick.

@hadnazzar

This comment has been minimized.

Copy link

hadnazzar commented Jun 7, 2018

On windows:
Run powershell as Administrator:
and run
npm --add-python-to-path='true' --debug install --global windows-build-tools

@iamveritas

This comment has been minimized.

Copy link

iamveritas commented Aug 17, 2018

in my case when I ran
npm --add-python-to-path='true' --debug install --global windows-build-tools
or
npm install --global --production windows-build-tools
it hags forever at this
---------- Visual Studio Build Tools ----------
Still waiting for installer log file...
---------- Visual Studio Build Tools ----------
Still waiting for installer log file...
------------------- Python --------------------

---------- Visual Studio Build Tools ----------
Successfully installed Visual Studio Build Tools
------------------- Python --------------------
=== Logging stopped: 8/17/2018 10:22:57 ===

@DanielRuf DanielRuf referenced this issue Aug 17, 2018

Merged

foundation-cli docs for windows users #11458

11 of 14 tasks complete
@brianHollingsworth

This comment has been minimized.

Copy link

brianHollingsworth commented Aug 20, 2018

Thank you, @ArminMa!

@felixrieseberg

This comment has been minimized.

Copy link
Owner

felixrieseberg commented Sep 1, 2018

Thank you all, we're quite confident that most of these issues are now fixed 🙇

@yume117

This comment has been minimized.

Copy link

yume117 commented Sep 20, 2018

Still getting this :

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 PythonFinder.failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd c:\Users\Julien.MARANTES\Documents\workspace\enfrasys\nbdtm-back\node_modules\unix-dgram
gyp ERR! node -v v8.11.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
@Saibamen

This comment has been minimized.

Copy link

Saibamen commented Sep 20, 2018

@yume117 you must close all CMD windows after installing windows-build-tools to refresh PATH env variable

@KrishnanSriram

This comment has been minimized.

Copy link

KrishnanSriram commented Sep 23, 2018

I see python in my PATH variable as well as set up python as a environment variable. Tried everthing from above. It keeps failing with the same error. Not sure, how to fix it. Any help would be deeply appreciated

C:\Users\krish\Projects\ethereum\helloworldreact\client>echo %python%
C:\Users\krish.windows-build-tools\python27

C:\Users\krish\Projects\ethereum\helloworldreact\client>echo %PATH%
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\nodejs;C:\Program Files\PuTTY;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Git\cmd;C:\Go\bin;**C:\Users\krish.windows-build-tools\python27;**C:\Users\krish\AppData\Local\Microsoft\WindowsApps;C:\Users\krish\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\krish\AppData\Roaming\npm;C:\Users\krish\AppData\Local\atom\bin;C:\Users\krish\AppData\Local\Microsoft\WindowsApps;C:\Users\krish\go\bin

C:\Users\krish\Projects\ethereum\helloworldreact\client\node_modules\keccak>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Users\krish.windows-build-tools\python27", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack at PythonFinder. (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:154:21)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\krish\Projects\ethereum\helloworldreact\client\node_modules\keccak
gyp ERR! node -v v10.11.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! keccak@1.4.0 rebuild: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the keccak@1.4.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\krish\AppData\Roaming\npm-cache_logs\2018-09-23T22_03_47_165Z-debug.log
"Keccak bindings compilation fail. Pure JS implementation will be used."

@Saibamen

This comment has been minimized.

Copy link

Saibamen commented Sep 27, 2018

What is your NPM and Node versions? (node --version and npm --version) Please update your Node version to latest LTS. Did you installed windows-build-tools from CMD with admin access? Installing windows-build-tools took some time. You must wait until installation is really finished

@KrishnanSriram

This comment has been minimized.

Copy link

KrishnanSriram commented Sep 29, 2018

npm - 6.4.1
node - 10.11.0

@KrishnanSriram

This comment has been minimized.

Copy link

KrishnanSriram commented Sep 29, 2018

I finally got it working with a very simple change. I re-installed Python for "All Users" insted of option "Only for me".

Updated Path variables for "python" & "path". Compilation worked well
Note: "truffle compile" does not work from "command prompt". But works well in "Powershell".

This was a minute work in LINUX & Mac, but a couple of days effort in Windows. When will Microsoft make Windows developer friendly????

@axeforeverjumo

This comment has been minimized.

Copy link

axeforeverjumo commented Oct 12, 2018

npm install --global --production windows-build-tools
Later installed this, you must specified the python2.7 link.

For that, you must search in your computer but must be locate in something like this:

C:\Users\USERNAME.windows-build-tools\python27\python.exe

So just execute this in your bash:

npm config set python "C:\Users\USERNAME.windows-build-tools\python27\python.exe"

@an-ivannikov

This comment has been minimized.

Copy link

an-ivannikov commented Oct 24, 2018

Need to fix hands.

PS G:\nodejs\test> node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@8.12.0 | win32 | x64
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 PythonFinder.failNoPython (C:\Users\Alex\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Users\Alex\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack     at C:\Users\Alex\AppData\Roaming\npm\node_modules\node-gyp\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Alex\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure"
gyp ERR! cwd G:\btc-test\rpc-miner
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

We're interested in that file. Change to your windows user name
C:\Users\Alex\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js
line number 32
var python = gyp.opts.python || process.env.PYTHON || 'python2'
change to your python location
var python = 'C:\\Python\\27\\python.exe'

function configure (gyp, argv, callback) {

  //var python = gyp.opts.python || process.env.PYTHON || 'python2'
  var python = 'C:\\Python\\27\\python.exe'
    , buildDir = path.resolve('build')
    , configNames = [ 'config.gypi', 'common.gypi' ]
    , configs = []
    , nodeDir
    , release = processRelease(argv, gyp, process.version, process.release)
@ramprasad2018

This comment has been minimized.

Copy link

ramprasad2018 commented Nov 11, 2018

Hi All,
I am trying to call a C++ module from Node.js by using the ADDONS. The node-gyp configure is getting failed with the following Error. I am surpise why it searches for Python? I am not using Python at all.
C:\Ram\Projects\GraphQL\t\addon>node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@10.13.0 | win32 | x64
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Software\Python37-32\python.exe -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:289:12)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at maybeClose (internal/child_process.js:962:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:381:11)
gyp ERR! stack at Socket.emit (events.js:182:13)
gyp ERR! stack at Pipe._handle.close (net.js:606:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\software\nodejs\node.exe" "C:\Users\Admin\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "configure"
gyp ERR! cwd C:\Ram\Projects\GraphQL\t\addon
gyp ERR! node -v v10.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

C:\Ram\Projects\GraphQL\t\addon>
capture

I also have attached the error.

Appreciate if any one can help.

@refack

This comment has been minimized.

Copy link

refack commented Nov 11, 2018

Hello @ramprasad2018, what you are seeing is a bug in node-gyp where it fails to notify you that it can only work with python2.
You can work around this until the fix is published, by running with:
node-gyp --python /path/to/python2.7
or setting:
npm config set python /path/to/executable/python2.7
Ref: https://github.com/nodejs/node-gyp#option-2

@kamaatakh

This comment has been minimized.

Copy link

kamaatakh commented Dec 5, 2018

solution: nfroidure/ttf2woff2#28
npm install --global --production windows-build-tools

In my case npm wasn't finding the python.exe file when trying to run npm rebuild node-sass. After running "npm install --global --production windows-build-tools", I was able to run the command.
Thanks @ArminMa

"Error: not found: C:\Users\username\.windows-build-tools\python27\python.exe"

@Lingweifeng

This comment has been minimized.

Copy link

Lingweifeng commented Dec 10, 2018

https://github.com/felixrieseberg/windows-build-tools/issues/33

npm --add-python-to-path='true' --debug install --global windows-build-tools

@ArminMa Thanks

@maikonmatheus

This comment has been minimized.

Copy link

maikonmatheus commented Jan 7, 2019

1 - Just uninstall Python from "C:\Users\username.windows-build-tools\python27"
2 - Reinstall running the msi install file, not command line. Link: https://www.python.org/downloads/release/python-2715/
2.1 - Check the option "Install for all users" and install on "C:\python27".

Now node-gyp will find the Python normally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment