Rando Shtishi
Rando Shtishi

Reputation: 1512

Cannot change the default python version used by the node-gyp?

When i run the the command the node-gyp rebuild command I get the following error:

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info find Python using Python version 3.8.5 found at "/usr/bin/python3"
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: ENOENT: no such file or directory, mkdir '/home/rando/.cache/node-gyp/9.6.1'
gyp ERR! System Linux 5.8.0-45-generic
gyp ERR! command "/home/rando/.nvm/versions/node/v9.6.1/bin/node" "/home/rando/.nvm/versions/node/v9.6.1/bin/node-gyp" "rebuild" "--python=/home/rando/.pyenv/versions/2.7.18/bin"
gyp ERR! cwd /home/rando/Desktop/git/master-node/node/browser_engines/src/browsers/webkit
gyp ERR! node -v v9.6.1
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok 

I have tried to change the node-gyp default python version like below:

And all comand resulted with the same Error. They are using python3 instead of python passed to configuration.

Environments Details

Upvotes: 10

Views: 11888

Answers (4)

Alex
Alex

Reputation: 9429

I solved my problems by switching node-gyp from python3 to python2

Options for configuring node-gyp python path are described here:
https://github.com/nodejs/node-gyp#configuring-python-dependency

Upvotes: -1

Rando Shtishi
Rando Shtishi

Reputation: 1512

I solved this issue by exporting the NODE_GYP_FORCE_PYTHON like below:

export  NODE_GYP_FORCE_PYTHON=$HOME/.pyenv/versions/2.7.18/bin/python
echo $NODE_GYP_FORCE_PYTHON

Upvotes: 7

Ashish Pani
Ashish Pani

Reputation: 1071

After setting NODE_GYP_FORCE_PYTHON, i was getting the error that python version is outdated. Required python version is >=3.6 .

With python3, it was giving syntax error as it was trying to execute something written with python2. So what worked for me is

yarn remove node-sass
yarn add node-sass
yarn install && yarn start

Upvotes: 1

Guilherme Garnier
Guilherme Garnier

Reputation: 2257

I've tried the suggestion from Rando Shtishi, but it didn't work. I've solved by exporting a PYTHON env var with that same value:

export PYTHON=$HOME/.pyenv/versions/2.7.18/bin/python

Upvotes: 2

Related Questions