简体   繁体   中英

Python not found for node-gyp

I am trying to npm install for a project in my mac but for some reason it says python not found even though python3 command is working fine and I also set alias python to python3 in by ~/.zshrc and ~/.bash-profile and restarted several times but still the same issue.

Screenshot of the issue.

在此处输入图像描述

NOTE: See comments for the solution

The problem is that Python is required in the system path to operate this command. Solutions:

  1. Install pyenv
  2. Install either Python 2.7 or Python 3.x: pyenv install 2.7.18 or pyenv install 3.9.11 (for example)
  3. If you have more than one python version, ensure one of them is set as global: pyenv global 3.9.11
  4. Add pyenv to your system path
    • On Mac, put this in your ~/.bashrc or ~/.zshrc : export PATH=$(pyenv root)/shims:$PATH , then run source ~/.bashrc or source ~/.zshrc
    • For Windows, try npm config set python C:\Library\Python\Python310\python.exe (for example) via administrator
  5. Run npm install again

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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