Skip to content
Advertisement

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 node-gyp@7.1.2
gyp info using node@9.6.1 | 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:

  • Command : node-gyp rebuild --python=/home/rando/.pyenv/versions/2.7.18/bin
  • Command : node-gyp rebuild --python=2.7
  • Command : node-gyp rebuild --python=2.7.18

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

Environments Details

  • OS: Ubuntu 20.04
  • Python Version: 2.7.18
  • Node version: V9.6.1

Advertisement

Answer

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
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement