Skip to content
This repository has been archived by the owner on Sep 11, 2021. It is now read-only.

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

Closed
mikew opened this issue Apr 23, 2017 · 64 comments
Closed

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

mikew opened this issue Apr 23, 2017 · 64 comments

Comments

@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
Copy link
Author

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

@tkgalk
Copy link

tkgalk commented May 12, 2017

Same issue here.

@choucry13
Copy link

+1

@garolion
Copy link

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

@felixrieseberg
Copy link
Owner

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
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
Copy link

jeanru commented Sep 6, 2017

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

@dougbacelar
Copy link

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

@harrodevos
Copy link

@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
Copy link

thuyvtgl commented Dec 6, 2017

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

@dhanabalcbt
Copy link

thanks arima

@Philip-Nunoo
Copy link

Thanks @ArminMa

@mapplics
Copy link

thanks @aminma you save my day!

@bibhuticoder
Copy link

Installing python 2.* worked for me.

@hallss93
Copy link

hallss93 commented Feb 8, 2018

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

@SatishMHiremath
Copy link

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
Copy link

walalm commented Jun 5, 2018

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

@hadnazzar
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

@lukos
Copy link

lukos commented Jun 12, 2019

The problem is more fundamental than is mentioned here. A node module should not have a hard dependency on a build system like Python or MSBuild unless it can download one and install it without privileges locally or hold the user's hand.

This package is a help but it doesn't solve the problem because if, for example, you need to install it from an admin account, it gets installed in the admin account which makes it unusable for the non-admin users.

I had to delete where it was installed and then manually install the Python executable for all users, but the modify path didn't seem to do anything because it still didn't work. I then manually added the PYTHON environment variable before it would work.

Thanks for this package but it should either have some more instructions, a better default example in the docs (and shouldn't be needed if people didn't make ridiculous node package like node_gyp)!

@rashmimilan
Copy link

rashmimilan commented Sep 20, 2019

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

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

Thank you so much @ArminMa!

@ghost
Copy link

ghost commented Oct 2, 2019

Special thanks goes to @ArminMa ! works for me!

@zaid757
Copy link

zaid757 commented Nov 22, 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

it works halfway for me after I install python I need to install visual studio_BuildTools manually and select few other package too . now its working fine

@tayyabarif41
Copy link

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

it worked <3

@brianli-whitbread
Copy link

brianli-whitbread commented Dec 11, 2019

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

@jeanru, this command destroyed my development machine.

To fix this, remove npm env variables from ~/.npmrc

@tijazz
Copy link

tijazz commented Dec 30, 2019

If you ever come across the above error on windows:
Run CMD as Administrator:
and run.
npm --add-python-to-path='true' --debug install --global windows-build-tools

that's all...

@B4Lee
Copy link

B4Lee commented Jan 7, 2020

I just solved the problem by reading this article

https://spin.atomicobject.com/2019/03/27/node-gyp-windows/

hope it helps !!

@ashutoshsoni
Copy link

Thanks Satish.

@divya-kanak
Copy link

Configuration: window 10, 64 bit, node v8.13.0, npm v6.4.1

Follow the below steps :

  1. Restart the system

  2. Open cmd by administrator

  3. Delete C:\Users\user_name.node-gyp

  4. Delete %AppData%/npm

  5. Delete %AppData%/npm-cache

  6. Check out node-gyp package

  7. npm install -g node-gyp

  8. npm install --global --production windows-build-tools

  9. node-gyp configure --python C:\Users\pcq158.windows-build-tools\python27\python.exe

  10. npm config set msvs_version 2017 --global

  11. npm install

@krychuq1
Copy link

I had to re-install python 2.7 and change npm python config to:

npm config set python "c:\Python27\python.exe"

@jawad-aziz-farhad
Copy link

For Ubuntu 18.04.4 LTS
npm --add-python-to-path='true' --debug install --global build-tools

@felloz
Copy link

felloz commented Sep 15, 2020

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

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! windows-build-tools@5.2.2 postinstall: `node ./dist/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the windows-build-tools@5.2.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\lserrano\AppData\Roaming\npm-cache\_logs\2020-09-15T18_29_25_510Z-debug.log

Still having the issue

@iwasherefirst2
Copy link

Its not working on Ubuntu:

npm --add-python-to-path='true' --debug install --global windows-build-tools
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for windows-build-tools@5.2.2: wanted {"os":"win32","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS:    win32
npm ERR! notsup Valid Arch:  any
npm ERR! notsup Actual OS:   linux
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/adam/.npm/_logs/2020-12-04T14_01_39_361Z-debug.log

Any ideas how to fix it on Linux?

@jacobq
Copy link
Collaborator

jacobq commented Dec 4, 2020 via email

@iwasherefirst2
Copy link

@jacobq whoups. Just realized that I was actually missing Python at all.lol..

@alvaropsouza
Copy link

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

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

i think i love you. it worked man, thanks a lot!

@SergeyAP
Copy link

Its not working on Ubuntu:

npm --add-python-to-path='true' --debug install --global windows-build-tools
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for windows-build-tools@5.2.2: wanted {"os":"win32","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS:    win32
npm ERR! notsup Valid Arch:  any
npm ERR! notsup Actual OS:   linux
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/adam/.npm/_logs/2020-12-04T14_01_39_361Z-debug.log

Any ideas how to fix it on Linux?

How did you fix it? i have the same problem on macos

@jacobq
Copy link
Collaborator

jacobq commented Jan 18, 2021

Its not working on Ubuntu: ...

How did you fix it? i have the same problem on macos

As the name windows-build-tools is intended to suggest, this package is for installing Windows software needed to build native extensions/modules for NodeJS. It is completely unnecessary on Linux and MacOS. If you are intending to "cross-compile" Windows things on a non-Windows platform then I recommend using a virtualization layer (e.g. VirtualBox, Parallels, etc.) or cloud CI/CD offering (e.g. AppVeyor).

@sotickmars
Copy link

run: npm cache clean --force
delete node_modules
delete packagelock.json and yarn.lock(if have)
run: npm install

@danieldanielecki
Copy link

danieldanielecki commented Mar 25, 2021

Installing Python from the official source fixed this issue on Windows after restarting the machine...

@reuniware
Copy link

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

Thanks !!

@OxQ
Copy link

OxQ commented May 31, 2021

Installing python (for Windows) using Microsoft Store has helped me.

@fabiovaz
Copy link

fabiovaz commented Jul 2, 2021

after install windows build tools type
npm config set msvs_version 2017
saved me

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests