简体   繁体   English

NPM安装无法在MAC中执行Python

[英]NPM install can't execute Python in MAC

I'm new to MAC (OSX version is High Sierra 10.13.3).我是 MAC 新手(OSX 版本是 High Sierra 10.13.3)。 I installed python 3.6.5 with the installer from python.org and I tried doing it with brew too by running brew install python .我使用 python.org 的安装程序安装了 python 3.6.5,我也尝试通过运行brew install python来使用brew install python Now, I'm trying to run sudo npm install in a Angular project and I get the following errors:现在,我正在尝试在 Angular 项目中运行sudo npm install ,但出现以下错误:

gyp verb check python checking for Python executable "/path/to/python3/python" in the PATH
gyp verb `which` failed Error: not found: /path/to/python3/python
gyp ERR! stack Error: Can't find Python executable "/path/to/python3/python", you can set the PYTHON env variable.

I have tried all the answers in here :我已经尝试了这里的所有答案:

python location on mac osx mac osx 上的 python 位置

Can't find Python executable "python" 找不到 Python 可执行文件“python”

Inside of my projects folder I do the following:在我的项目文件夹中,我执行以下操作:

when I type 'which python' I get:当我输入“which python”时,我得到:

/usr/local/opt/python/libexec/bin/python

When I type 'which python3.6.5' I get:当我输入“which python3.6.5”时,我得到:

/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6

It looks like my node_modules folder was screwed up. 看来我的node_modules文件夹搞砸了。 I deleted the repo and cloned again and it worked. 我删除了该存储库,然后再次克隆,它可以正常工作。

For me it was all happening because of nodejs version.对我来说,这一切都是因为 nodejs 版本而发生的。

Node version 16+ does not support "node-sass": "^4.14.1", so I have to install nvm and downgrade the nodesjs in macbook as follows Node 16+版本不支持“node-sass”:“^4.14.1”,所以我必须安装nvm并降级macbook中的nodejs如下

  • Before installing nvm, run this in terminal: touch ~/.bash_profile在安装 nvm 之前,在终端中运行: touch ~/.bash_profile

  • After, run this in terminal: curl -o-之后,在终端中运行: curl -o-
    https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash猛击

  • Important... - DO NOT forget to Restart your terminal OR use command source ~/.nvm/nvm.sh (this will refresh the available commands in重要... - 不要忘记重新启动终端或使用命令源 ~/.nvm/nvm.sh (这将刷新可用命令
    your system path).您的系统路径)。

  • In the terminal, use command nvm --version and you should see the在终端中,使用命令nvm --version你应该看到
    version版本

  • bash nvm install 14.17.0 bash nvm 安装 14.17.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM