NVM为什么使用不正确的Python版本?

问题描述 投票:0回答:1

我在node-gyp包方面遇到了一些问题,并且我认为这是因为我需要使用python 2.7而不是python 3。

我已经设置了PATH环境变量,以便在执行python --version时输出为Python 2.7.16

但是,在同一终端中,当我转到yarn时,请安装我的项目。它失败了,我可以看到日志的输出是:

Command: node-gyp rebuild
Arguments:
Directory: /Users/myname/Documents/myproject
Output:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info find Python using Python version 3.7.3 found at "/Users/myname/anaconda3/bin/python"

我也在使用nvm。卡塔琳娜10.15.2。节点12.14.0。 NVM 0.33.11。

为什么我的终端版本显示我使用2.7,但是日志显示命令node-gyp rebuild使用3.7.3?如果我已经设置了环境变量,该如何更改以纠正此问题?与nvm有关吗?

python node.js macos nvm
1个回答
0
投票

已解决!您可以这样做:

npm install --python=python2.7

或将其设置为始终使用:

npm config set python python2.7

从这里捏=> How to use a different version of python during NPM install?

© www.soinside.com 2019 - 2024. All rights reserved.