title: Yarn install throws error: gyp verb `which` failed Error: not found: python2
body: <p>In a React Project I am trying to run &quot;yarn install&quot; but it is throwing the following error:</p>
  <blockquote>
  <p>gyp verb <code>which</code> failed Error: not found: python2</p>
  </blockquote>
  <p>Full Error traceback:</p>
  <pre><code>yarn install v1.22.4
  warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
  [1/4] Resolving packages...
  [2/4] Fetching packages...
  info fsevents@2.1.2: The platform &quot;win32&quot; is incompatible with this module.
  info &quot;fsevents@2.1.2&quot; is an optional dependency and failed compatibility check. Excluding it from installation.
  info fsevents@1.2.12: The platform &quot;win32&quot; is incompatible with this module.
  info &quot;fsevents@1.2.12&quot; is an optional dependency and failed compatibility check. Excluding it from installation.
  [3/4] Linking dependencies...
  warning &quot; &gt; @coreui/coreui@3.0.0&quot; has unmet peer dependency &quot;perfect-scrollbar@^1.5.0&quot;.
  warning &quot; &gt; @coreui/coreui@3.0.0&quot; has unmet peer dependency &quot;@popperjs/core@^2.0.6&quot;.
  warning &quot; &gt; @coreui/react@2.5.7&quot; has incorrect peer dependency &quot;@coreui/coreui@^2.1.16&quot;.
  warning &quot; &gt; @coreui/react@2.5.7&quot; has unmet peer dependency &quot;mutationobserver-shim@^0.3.3&quot;.
  warning &quot; &gt; @testing-library/user-event@7.2.1&quot; has unmet peer dependency &quot;@testing-library/dom@&gt;=5&quot;.
  warning &quot; &gt; react-bootstrap-table-next@4.0.1&quot; has unmet peer dependency &quot;classnames@^2.2.5&quot;.
  warning &quot; &gt; react-bootstrap-table-next@4.0.1&quot; has unmet peer dependency &quot;prop-types@^15.0.0&quot;.
  warning &quot;react-scripts &gt; @typescript-eslint/eslint-plugin &gt; tsutils@3.17.1&quot; has unmet peer dependency &quot;typescript@&gt;=2.8.0 || &gt;= 3.2.0-dev || &gt;= 3.3.0-dev || &gt;= 3.4.0-dev || &gt;= 3.5.0-dev || &gt;= 3.6.0-dev || &gt;= 3.
  6.0-beta || &gt;= 3.7.0-dev || &gt;= 3.7.0-beta&quot;.
  [4/4] Building fresh packages...
  [-/4] ⡀ waiting...
  [-/4] ⡀ waiting...
  [3/4] ⡀ node-sass
  error C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-sass: Command failed.
  Exit code: 1
  Command: node scripts/build.js
  Arguments:
  Directory: C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-sass
  Output:
  Binary found at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-sass\vendor\win32-x64-72\binding.node
  Testing binary
  Binary has a problem: Error: Cannot find module './_baseClone'
  Require stack:
  - C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\lodash\cloneDeep.js
  - C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-sass\lib\index.js
  - C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-sass\scripts\build.js
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
      at Function.Module._load (internal/modules/cjs/loader.js:840:27)
      at Module.require (internal/modules/cjs/loader.js:1019:19)
      at require (internal/modules/cjs/helpers.js:77:18)
      at Object.&lt;anonymous&gt; (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\lodash\cloneDeep.js:1:17)
      at Module._compile (internal/modules/cjs/loader.js:1133:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
      at Module.load (internal/modules/cjs/loader.js:977:32)
      at Function.Module._load (internal/modules/cjs/loader.js:877:14)
      at Module.require (internal/modules/cjs/loader.js:1019:19) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
      'C:\\Users\\Rahul\\yantra-front\\cargo_frontend\\cargo-app\\node_modules\\lodash\\cloneDeep.js',
      'C:\\Users\\Rahul\\yantra-front\\cargo_frontend\\cargo-app\\node_modules\\node-sass\\lib\\index.js',
      'C:\\Users\\Rahul\\yantra-front\\cargo_frontend\\cargo-app\\node_modules\\node-sass\\scripts\\build.js'
    ]
  }
  Building the binary locally
  Building: C:\Program Files\nodejs\node.exe C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libs
  ass_library=
  gyp info it worked if it ends with ok
  gyp verb cli [
  gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
  gyp verb cli   'C:\\Users\\Rahul\\yantra-front\\cargo_frontend\\cargo-app\\node_modules\\node-gyp\\bin\\node-gyp.js',
  gyp verb cli   'rebuild',
  gyp verb cli   '--verbose',
  gyp verb cli   '--libsass_ext=',
  gyp verb cli   '--libsass_cflags=',
  gyp verb cli   '--libsass_ldflags=',
  gyp verb cli   '--libsass_library='
  gyp verb cli ]
  gyp info using node-gyp@3.8.0
  gyp info using node@12.16.3 | win32 | x64
  gyp verb command rebuild []
  gyp verb command clean []
  gyp verb clean removing &quot;build&quot; directory
  gyp verb command configure []
  gyp verb check python checking for Python executable &quot;python2&quot; in the PATH
  gyp verb `which` failed Error: not found: python2
  gyp verb `which` failed     at getNotFoundError (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:13:12)
  gyp verb `which` failed     at F (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:68:19)
  gyp verb `which` failed     at E (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:80:29)
  gyp verb `which` failed     at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:89:16
  gyp verb `which` failed     at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\isexe\index.js:42:5
  gyp verb `which` failed     at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\isexe\windows.js:36:5
  gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:167:21)
  gyp verb `which` failed  python2 Error: not found: python2
  gyp verb `which` failed     at getNotFoundError (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:13:12)
  gyp verb `which` failed     at F (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:68:19)
  gyp verb `which` failed     at E (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:80:29)
  gyp verb `which` failed     at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:89:16
  gyp verb `which` failed     at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\isexe\index.js:42:5
  gyp verb `which` failed     at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\isexe\windows.js:36:5
  gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:167:21) {
  gyp verb `which` failed   code: 'ENOENT'
  gyp verb `which` failed }
  gyp verb check python checking for Python executable &quot;python&quot; in the PATH
  gyp verb `which` succeeded python C:\Users\Rahul\AppData\Local\Programs\Python\Python37\python.EXE
  gyp ERR! configure error
  gyp ERR! stack Error: Command failed: C:\Users\Rahul\AppData\Local\Programs\Python\Python37\python.EXE -c import sys; print &quot;%s.%s.%s&quot; % sys.version_info[:3];
  gyp ERR! stack   File &quot;&lt;string&gt;&quot;, line 1
  gyp ERR! stack     import sys; print &quot;%s.%s.%s&quot; % sys.version_info[:3];
  gyp ERR! stack                                ^
  gyp ERR! stack SyntaxError: invalid syntax
  gyp ERR! stack
  gyp ERR! stack     at ChildProcess.exithandler (child_process.js:303:12)
  gyp ERR! stack     at ChildProcess.emit (events.js:310:20)
  gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
  gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
  gyp ERR! System Windows_NT 10.0.18362
  gyp ERR! command &quot;C:\\Program Files\\nodejs\\node.exe&quot; &quot;C:\\Users\\Rahul\\yantra-front\\cargo_frontend\\cargo-app\\node_modules\\node-gyp\\bin\\node-gyp.js&quot; &quot;rebuild&quot; &quot;--verbose&quot; &quot;--libsass_ext=&quot; &quot;--libsass_cfl
  ags=&quot; &quot;--libsass_ldflags=&quot; &quot;--libsass_library=&quot;
  gyp ERR! cwd C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-sass
  gyp ERR! node -v v12.16.3
  gyp ERR! node-gyp -v v3.8.0
  </code></pre>
  <p>Whereas I have both python 3 as well as 2 in my path</p>
  <pre><code>C:\Python27;C:\Python27\Tools\Scripts
  C:\Users\Rahul\.windows-build-tools\python27\
  C:\Users\Rahul\AppData\Local\Programs\Python\Python37\
  C:\Users\Rahul\AppData\Local\Programs\Python\Python37\Scripts\
  C:\Users\Rahul\AppData\Roaming\npm
  C:\Users\Rahul\AppData\Local\Yarn\bin
  C:\Users\Rahul\AppData\Local\Microsoft\WindowsApps
  %USERPROFILE%\AppData\Local\Microsoft\WindowsApps
  </code></pre>
  <p>I am failing to run the project. Please Help!!</p>
  <p>package.json</p>
  <pre><code>{
    &quot;name&quot;: &quot;cargo-app&quot;,
    &quot;version&quot;: &quot;0.1.0&quot;,
    &quot;private&quot;: true,
    &quot;dependencies&quot;: {
      &quot;@coreui/coreui&quot;: &quot;^3.0.0&quot;,
      &quot;@coreui/react&quot;: &quot;^2.5.7&quot;,
      &quot;@fortawesome/fontawesome-svg-core&quot;: &quot;^1.2.28&quot;,
      &quot;@fortawesome/free-solid-svg-icons&quot;: &quot;^5.13.0&quot;,
      &quot;@fortawesome/react-fontawesome&quot;: &quot;^0.1.9&quot;,
      &quot;@testing-library/jest-dom&quot;: &quot;^4.2.4&quot;,
      &quot;@testing-library/react&quot;: &quot;^9.3.2&quot;,
      &quot;@testing-library/user-event&quot;: &quot;^7.1.2&quot;,
      &quot;axios&quot;: &quot;^0.19.2&quot;,
      &quot;history&quot;: &quot;^4.10.1&quot;,
      &quot;node-sass&quot;: &quot;^4.14.1&quot;,
      &quot;react&quot;: &quot;^16.13.1&quot;,
      &quot;react-bootstrap-table-next&quot;: &quot;^4.0.1&quot;,
      &quot;react-dom&quot;: &quot;^16.13.1&quot;,
      &quot;react-redux&quot;: &quot;^7.2.0&quot;,
      &quot;react-router-dom&quot;: &quot;^5.1.2&quot;,
      &quot;react-scripts&quot;: &quot;3.4.1&quot;,
      &quot;react-toastify&quot;: &quot;^6.0.0&quot;,
      &quot;reactjs-localstorage&quot;: &quot;^0.0.8&quot;,
      &quot;reactstrap&quot;: &quot;^8.4.1&quot;,
      &quot;redux&quot;: &quot;^4.0.5&quot;,
      &quot;redux-thunk&quot;: &quot;^2.3.0&quot;
    },
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;react-scripts start&quot;,
      &quot;build&quot;: &quot;react-scripts build&quot;,
      &quot;test&quot;: &quot;react-scripts test&quot;,
      &quot;eject&quot;: &quot;react-scripts eject&quot;
    },
    &quot;eslintConfig&quot;: {
      &quot;extends&quot;: &quot;react-app&quot;
    },
    &quot;browserslist&quot;: {
      &quot;production&quot;: [
        &quot;&gt;0.2%&quot;,
        &quot;not dead&quot;,
        &quot;not op_mini all&quot;
      ],
      &quot;development&quot;: [
        &quot;last 1 chrome version&quot;,
        &quot;last 1 firefox version&quot;,
        &quot;last 1 safari version&quot;
      ]
    }
  }
  </code></pre>