[email protected] Install Fails with Yarn

Question:

The following install fails:

$ sudo yarn add -P [email protected]

Here’s the error:

gyp ERR! configure error 
gyp ERR! stack Error: Python executable "/anaconda3/bin/python" is v3.6.4, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.

If I were using ‘npm’ as the package manager, the following command would resolve the issue:

$ sudo npm install --save [email protected] --python=pyhon2.7

But, I bootstrapped my project with ‘create-react-app’, which defaults to using ‘yarn’ as the package manager.

So, what’s the syntax for switching versions of python, using ‘yarn’, as mentioned in the error message. I’ve gone through guessing several variations to no avail. And, I’m not finding any solution that fits the circumstance.

Asked By: Ron Allen Smith

||

Answers:

Try setting python version as an environmental variable.

npm config --global set python /usr/bin/python2.7

You can read more about this in this issue

Answered By: sudo bangbang