npm - “找不到 Python 可执行文件“python”,您可以设置 PYTHON 环境变量。”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34372618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm - "Can't find Python executable "python", you can set the PYTHON env variable."
提问by Nick
I'm trying to run the following command: npm install -g bower gulp cordova ionic tsd@next karma-cli protractor node-gyp coffee-script js-beautify typescript npm-check
我正在尝试运行以下命令: npm install -g bower gulp cordova ionic tsd@next karma-cli protractor node-gyp coffee-script js-beautify typescript npm-check
I have installed Python, Visual Studio Express and node-gyp so thought I'd be good to go, however I get the following errors:
我已经安装了 Python、Visual Studio Express 和 node-gyp,所以我认为我很高兴,但是我收到以下错误:
Regarding the "Can't find Python executable "python", you can set the PYTHON env variable."
error, I'm a little confused because I have set the PYTHON environmental variable like so:
关于"Can't find Python executable "python", you can set the PYTHON env variable."
错误,我有点困惑,因为我已经像这样设置了 PYTHON 环境变量:
Any ideas please?
请问有什么想法吗?
采纳答案by jvecsei
You got to add python to your PATH variable. One thing you can do is Edit your Path variable now and add
您必须将 python 添加到您的 PATH 变量中。您可以做的一件事是现在编辑您的 Path 变量并添加
;%PYTHON%;
;%PYTHON%;
Your variable PYTHON should point to the root directory of your python installation.
你的变量 PYTHON 应该指向你的 python 安装的根目录。
回答by OneCricketeer
You are running the Command Prompt as an admin. You have only defined PYTHON for your user. You need to define it in the bottom "System variables" section.
您正在以管理员身份运行命令提示符。您只为您的用户定义了 PYTHON。您需要在底部的“系统变量”部分定义它。
Also, you should only point the variable to the folder, not directly to the executable.
此外,您应该只将变量指向文件夹,而不是直接指向可执行文件。
回答by Tom Gao
https://github.com/nodejs/node-gyp#on-windows
https://github.com/nodejs/node-gyp#on-windows
try
尝试
npm config set python D:\Library\Python\Python27\python.exe
回答by gus
I installed python2.7 to solve this issue. I wish can help you.
我安装了python2.7来解决这个问题。我希望能帮到你。
回答by kuan tein
Try:
尝试:
Install all the required tools and configurations using Microsoft's windows-build-tools by running npm install -g windows-build-tools
from an elevated PowerShell(run as Administrator).
通过npm install -g windows-build-tools
从提升的PowerShell(以管理员身份运行)运行,使用 Microsoft 的 windows-build-tools 安装所有必需的工具和配置。
回答by Shamseer Ahammed
The easiest way is to let NPM do everything for you,
最简单的方法是让 NPM 为你做一切,
npm --add-python-to-path='true' --debug install --global windows-build-tools
回答by Elharony
One of the following solutions will work for you:
以下解决方案之一适合您:
- npm config set python
c:\Python\27\python.exe
orset PYTHON=D:\Python\bin\Python.exe
npm config set python D:\Library\Python\Python27\python.exe
- Let npm configure everything for you (takes forever to complete)
npm --add-python-to-path='true' --debug install --global windows-build-tools
(Must be executed via "Run As Administrator" PowerShell)
- npm 配置集 python
c:\Python\27\python.exe
或set PYTHON=D:\Python\bin\Python.exe
npm config set python D:\Library\Python\Python27\python.exe
- 让 npm 为您配置一切(需要永远完成)
npm --add-python-to-path='true' --debug install --global windows-build-tools
(必须通过“以管理员身份运行”PowerShell 执行)
If not... Try to install the required package on your own (I did so, and it was node-sass
, after installing it manually, the whole npm install
was successfully completed
如果没有...尝试自己安装所需的包(我是这样做的,而且是node-sass
,手动安装后,整个npm install
成功完成
回答by Lahiru Amarathunge
Just run below command with admin access
只需在具有管理员访问权限的命令下运行
npm install --global --production windows-build-tools
npm install --global --production windows-build-tools