gyp ERR! find Python 解决方案

命令行报错

npm install 
npm WARN deprecated fsevents@2.1.3: "Please update to latest v2.3 or v2.2"
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.

> heapdump@0.3.15 install D:\Work\XXX\node_modules\heapdump
> node-gyp rebuild


D:\Work\XXX\node_modules\heapdump>if not defined npm_config_node_gyp (node "C:\Users\BBB\AppData\Roaming\nvm\v14.20.0\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebu
ild )  else (node "C:\Users\BBB\AppData\Roaming\nvm\v14.20.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! find Python 
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python checking if the py launcher can be used to find Python 2
gyp ERR! find Python - "py.exe" is not in PATH or produced an error
gyp ERR! find Python checking if Python is C:\Python27\python.exe
gyp ERR! find Python - "C:\Python27\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Python37\python.exe
gyp ERR! find Python - "C:\Python37\python.exe" could not be run
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="C:\Path\To\python.exe"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "C:\Path\To\python.exe"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (C:\Users\BBB\AppData\Roaming\nvm\v14.20.0\node_modules\npm\node_modules\node-gyp\lib\find-python.js:307:47)
gyp ERR! stack     at PythonFinder.runChecks (C:\Users\BBB\AppData\Roaming\nvm\v14.20.0\node_modules\npm\node_modules\node-gyp\lib\find-python.js:136:21)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Users\BBB\AppData\Roaming\nvm\v14.20.0\node_modules\npm\node_modules\node-gyp\lib\find-python.js:225:16)
gyp ERR! stack     at PythonFinder.execFileCallback (C:\Users\BBB\AppData\Roaming\nvm\v14.20.0\node_modules\npm\node_modules\node-gyp\lib\find-python.js:271:16)
gyp ERR! stack     at exithandler (child_process.js:390:5)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! heapdump@0.3.15 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the heapdump@0.3.15 install 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\BBB\AppData\Roaming\npm-cache\_logs\2023-03-20T08_52_13_595Z-debug.log

根据报错提示python环境问题

操作步骤

1、安装node-gyp

npm install -g node-gyp

2、安装python

https://www.python.org/download/releases/2.7/

选择2.7.0的版本
在这里插入图片描述
安装一步步操作即可

3、配置python环境变量

如果没更改路径 是在你的C盘
在这里插入图片描述
测试是否安装成功
在这里插入图片描述

4、配置环境变量

点击 我的电脑–属性–高级系统设置–环境变量–系统变量–Path --新增
在这里插入图片描述

5、npm 配置

这里我都是默认的安装路径没有改

npm config set python “C:\Python27\python.exe”
npm config set node_gyp “C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js”

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
回答: 当你在使用npm时遇到"npm ERR! gyp ERR! find Python"的错误时,这通常是因为你的项目需要使用特定版本的node。你可以通过查看项目中的package.json文件来确定所需的node版本。在package.json文件中,你可以找到"@types/node"的版本号,例如"^14.14.37"。这表示你的项目需要使用14.14.37版本的node。\[1\] 在解决这个问题的过程中,有两种方法可以尝试。旧的解决方法是下载并安装对应版本的Python,例如Python 2.7。你可以从官方网站下载Python 2.7并进行安装。安装完成后,你需要修改环境变量。你可以通过右键点击"此电脑",选择"属性",然后进入"高级系统设置",在"高级"选项卡下找到"环境变量",在上半部分进行修改。这是一个简单的示例,你可以在百度上找到完整的教程来修改环境变量。\[2\] 另一种新的解决方法是使用管理员权限打开命令行,并执行以下命令:npm install --global --production windows-build-tools。这个命令将安装Windows构建工具,它包含了所需的Python版本。这种方法可以更方便地解决问题。\[2\] 综上所述,你可以根据项目中的package.json文件确定所需的node版本,并尝试使用旧的或新的解决方法来解决"npm ERR! gyp ERR! find Python"的错误。 #### 引用[.reference_title] - *1* [项目install的时候报错gyp ERR! find Python](https://blog.csdn.net/Anyuegogogo/article/details/128345133)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [npm install / yarn 执行的时候报错 gyp ERR! find Python 解决方案](https://blog.csdn.net/wangtao88888888/article/details/106681641)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值