"python" 环境变量设置在哪里?

Where is the "python" environment variable set?

我 运行 遇到了为 Windows 10 上的应用程序安装一些 npm 包的问题。具体来说,gyp 似乎引起了麻烦,因为它找不到 python 可执行文件.

这是 PowerShell 中 npm install 的部分输出:

之前我安装了 Cygwin,但后来我删除了它,更新为 Windows 10 并为 Windows 安装了 Linux 子系统。但显然 Cygwin python 路径仍然在某个环境变量中设置。

问题是,我找不到这个环境变量。

python 环境变量设置为 C:\Users\myaccount\.windows-build-tools\python27\python.exe

path 环境变量仅包含 C:\Users\myaccount\.windows-build-tools\python27\,没有其他 python 目录。

没有pythonpath环境变量。

我使用 PowerShell 和扩展系统设置检查了所有这些变量。

npm 或 gyp 的 python 路径来自哪里?

事实证明,在查看环境变量之前 gypnpm-config 中查找 python 条目。在我的例子中,python 条目设置如下:

; userconfig C:\Users\myaccount\.npmrc
python = "C:\cygwin64\bin\python2.7.exe"

删除 npm-config 中的 python 条目后

npm config delete python

gyp 通过 python 环境变量找到 python 可执行文件。