相关文章推荐
憨厚的充值卡  ·  react ...·  3 天前    · 
悲伤的熊猫  ·  React ...·  3 天前    · 
爱热闹的竹笋  ·  Windows.h 文件学习 - ...·  11 月前    · 
强健的太阳  ·  LeetCode ...·  1 年前    · 
鬼畜的松球  ·  void (C++) | ...·  1 年前    · 
干练的白开水  ·  DataGrid 控件概述 - ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm getting the error "Error: Can't find Python executable "python", you can set the PYTHON env variable"

when running the npm install command on a React project in Visual Studio Code on Macbook M1 .

Python is installed with brew but it still gives the error:

brew install python

Warning: [email protected] 3.11.2_1 is already installed and up-to-date. To reinstall 3.11.2_1, run: brew reinstall [email protected]

But I can`t use python version command

▶ python --version

zsh: command not found: python

Errors

gyp verb check python checking for Python executable "python2" in the PATH gyp verb which failed Error: not found: python2

gyp verb check python checking for Python executable "python" in the PATH gyp verb which failed Error: not found: python

Package.json

{ "name": "my-project",
      "version": "1.0.0",
      "private": true,
      "dependencies": {
        "@ckeditor/ckeditor5-build-classic": "^18.0.0",
        "@ckeditor/ckeditor5-react": "^2.1.0",
        "@devexpress/dx-react-core": "^2.7.5",
        "@devexpress/dx-react-grid": "^2.7.5",
        "@devexpress/dx-react-grid-bootstrap4": "^2.7.5",
        "axios": "^0.21.1",
        "bootstrap": "^4.6.0",
        "cpf-cnpj-validator": "^1.0.3",
        "crypto-js": "^4.0.0",
        "custom-error": "^0.2.1",
        "draft-js": "^0.11.7",
        "draft-js-export-html": "^1.4.1",
        "draft-js-import-html": "^1.4.1",
        "firebase": "^8.4.1",
        "firebase-tools": "^7.16.2",
        "fs": "0.0.1-security",
        "google-maps-react": "^2.0.6",
        "install": "^0.13.0",
        "jquery": "^3.6.0",
        "js-base64": "^2.6.4",
        "js-md5": "^0.7.3",
        "moment": "^2.29.1",
        "node-sass": "^4.14.1",
        "qrcode.react": "^0.9.3",
        "react": "^16.14.0",
        "react-autosuggest": "^9.4.3",
        "react-confirm-alert": "^2.7.0",
        "react-currency-input": "^1.3.6",
        "react-datepicker": "^2.16.0",
        "react-dom": "^16.14.0",
        "react-file-viewer": "^1.2.1",
        "react-filter-search": "^1.0.11",
        "react-html-parser": "^2.0.2",
        "react-input-mask": "^2.0.4",
        "react-intl-currency-input": "^0.2.6",
        "react-lazy-load-image-component": "^1.5.1",
        "react-loading-skeleton": "^2.2.0",
        "react-lottie": "^1.2.3",
        "react-notification-alert": "0.0.12",
        "react-places-autocomplete": "^7.3.0",
        "react-redux": "^7.2.3",
        "react-responsive-carousel": "^3.2.18",
        "react-router-dom": "^5.2.0",
        "react-scripts": "^3.4.4",
        "react-select": "^3.2.0",
        "reactstrap": "^8.9.0",
        "redux": "^4.0.5",
        "valid-url": "^1.0.9"
      "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject",
        "deploy:dev": "firebase deploy --only hosting:ingresso-gospel-dev",
        "deploy": "firebase deploy",
        "build:deploy": "npm run build && node node_modules/react-build-cache && firebase deploy"
      "eslintConfig": {
        "extends": "react-app"
      "browserslist": {
        "production": [
          ">0.2%",
          "not dead",
          "not op_mini all"
        "development": [
          "last 1 chrome version",
          "last 1 firefox version",
          "last 1 safari version"
      "devDependencies": {
        "eslint-plugin-react-hooks": "^2.5.1",
        "react-build-cache": "^1.1.4"

I need to use pyenv because python 2.x was having problems with macbook

Solution that worked for me

brew install pyenv

pyenv install 2.7.18

pyenv global 2.7.18

eval "$(pyenv init --path)"

source ~/.zprofile

and then the npm install worked fine

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.