Running Python on Windows for Node.js dependencies
Your problem is that you didn't set the environment variable.
The error clearly says this:
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
And in your comment, you say you did this:
set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib
That's nice, but that doesn't set the PYTHON
variable, it sets the PYTHONPATH
variable.
Meanwhile, just using the set
command only affects the current cmd
session. If you reboot after that, as you say you did, you end up with a whole new cmd
session that doesn't have that variable set in it.
There are a few ways to set environment variables permanently—the easiest is in the System Control Panel in XP, which is of course different in Vista, different again in 7, and different again in 8, but you can google for it.
Alternatively, just do the set
right before the npm
command, without rebooting in between.
You can test whether you've done things right by doing the exact same thing the config script is trying to do: Before running npm
, try running %PYTHON%
. If you've done it right, you'll get a Python interpreter (which you can immediately quit). If you get an error, you haven't done it right.
There are two problems with this:
set PYTHON=%PYTHON%;D:\Python
First, you're setting PYTHON
to ;D:\Python
. That extra semicolon is fine for a semicolon-separated list of paths, like PATH
or PYTHONPATH
, but not for a single value like PYTHON
. And likewise, adding a new value to the existing value is what you want when you want to add another path to a list of paths, but not for a single value. So, you just want set PYTHON=D:\Python
.
Second, D:\Python
is not the path to your Python interpreter. It's something like D:\Python\Python.exe
, or D:\Python\bin\Python.exe
. Find the right path, make sure it works on its own (e.g., type D:\Python\bin\Python.exe
and make sure you get a Python interpreter), then set the variable and use it.
So:
set PYTHON=D:\Python\bin\Python.exe
Or, if you want to make it permanent, do the equivalent in the Control Panel.
npm - Can't find Python executable python, you can set the PYTHON env variable.
You got to add python to your PATH variable. One thing you can do is Edit your Path variable now and add
;%PYTHON%;
Your variable PYTHON should point to the root directory of your python installation.
Node.js: Python not found exception due to node-sass and node-gyp
Node-sass tries to download the binary for you platform when installing. Node 5 is supported by 3.8 https://github.com/sass/node-sass/releases/tag/v3.8.0
If your Jenkins can't download the prebuilt binary, then you need to follow the platform requirements on Node-gyp README (Python2, VS or MSBuild, ...)
If possible I'd suggest updating your Node to at least 6 since 5 isn't supported by Node anymore.
If you want to upgrade to 8, you'll need to update node-sass to 4.5.3
Npm Error: Can't find Python executable python, you can set the PYTHON env variable on Windows 10
please set Python path in windows :
---For Windows 10/8/7:
- Open System Properties (Right click Computer in the start menu, or use the keyboard shortcut Win+Pause)
- Click Advanced system settings in the sidebar.
- Click Environment Variables...
- Select PATH in the System variables section
- Click Edit
- Add Python's path to the end of the list (the paths are separated by semicolons). For
example:
C:\Windows;C:\Windows\System32;C:\Python27
How to use a different version of python during NPM install?
You can use --python
option to npm like so:
npm install --python=python2.7
or set it to be used always:
npm config set python python2.7
Npm will in turn pass this option to node-gyp when needed.
(note: I'm the one who opened an issue on Github to have this included in the docs, as there were so many questions about it ;-) )
Python not found as dependency during ' npm jsbin' installation. What is missing?
I could not find out why NPN wasn't installing python, but then I tried it with a different installer, choco (or Chocolatey), which succeeded.
Steps are:
- Install Chocolatey. See Chocolatey website for instructions
- Open administrator console, then do the following:
C:\WINDOWS\system32>
choco install python
!!ATTENTION!!
The next version of Chocolatey (v0.9.9) will require -y to perform
behaviors that change state without prompting for confirmation. Start
using it now in your automated scripts.
For details on the all new Chocolatey, visit http://bit.ly/new_choco
Chocolatey (v0.9.8.33) is installing 'python' and dependencies.
By installing you accept the license for 'python' and each dependency you are installing.
python v3.4.3
Using this proxyserver: defrceprx02.ey.net:8443
Downloading python 64 bit
from 'https://www.python.org/ftp/python/3.4.3/python-3.4.3.amd64.msi'
Using this proxyserver: defrceprx02.ey.net:8443
Installing python...
python has been installed.
python has finished successfully! The chocolatey gods have answered your request!
PATH environment variable does not have C:\tools\python in it. Adding...
Finished installing 'python' and dependencies - if errors not shown in console, none detected.
Check log for errors if unsure.
C:\WINDOWS\system32>
Related Topics
Filling in Login Forms in Instagram Using Selenium and Webdriver (Chrome) Python Osx
Accessing Mp3 Metadata with Python
Python: Best Practice and Securest Way to Connect to MySQL and Execute Queries
How to Make a For-Loop Pyramid More Concise in Python
Function Changes List Values and Not Variable Values in Python
Django Modelform for Many-To-Many Fields
How to Set Timeout on Python's Socket Recv Method
Search for String in All Pandas Dataframe Columns and Filter
How to Kill a Process on Windows from Within Python
Numpy Random Choice to Produce a 2D-Array with All Unique Values
Log into Gmail Using Selenium in Python
Convert Rgba Png to Rgb with Pil
Cleanest Way to Get Last Item from Python Iterator
Why Does Str(Float) Return More Digits in Python 3 Than Python 2
Unicodedecodeerror When Redirecting to File