DEV Community

Cover image for Solution of "Can't find Python executable 'python'" Node Error
Hasan TEZCAN
Hasan TEZCAN

Posted on • Edited on

Solution of "Can't find Python executable 'python'" Node Error

Hello everyone, today we will take a look at a mix-in problem. The main reason of this situation is deprecated dependencies.

Image description

The project that we developed use a node version 14.18.0 and we use a node-sass version 4.14.1 package and this package also deprecated for today.

PS: You can use normal sass package today instead of node-sass.

The error out looks like these



Error: Can't find Python executable "python", you can set the PYTHON env variable.


Enter fullscreen mode Exit fullscreen mode

The python3 was already installed on my pc. But this is not helped at all.

We need to install python 2.7.18

We can use pyenv to work multiple python version. Let's download it.

1- Install "pyenv"



brew install pyenv


Enter fullscreen mode Exit fullscreen mode

2- Install the "2.7.18" version of python



pyenv install 2.7.18


Enter fullscreen mode Exit fullscreen mode

and set it as a global



pyenv global 2.7.18


Enter fullscreen mode Exit fullscreen mode

3- Add python executable directory to PATH



export PATH="${HOME}/.pyenv/shims:${PATH}"


Enter fullscreen mode Exit fullscreen mode

You can check the PATHs with;



echo $PATH


Enter fullscreen mode Exit fullscreen mode

4- Add python executable directory to the .npmrc



npm config set python $(which python)


Enter fullscreen mode Exit fullscreen mode

You can check the config with



npm config list 


Enter fullscreen mode Exit fullscreen mode

Image description

or check from .npmrc;



cat .npmrc


Enter fullscreen mode Exit fullscreen mode

Image description

After these steps, you can able to work with "python" and the node starts to will work with the "python" alias.

Arrivederci πŸ‘‹


Source:

Top comments (3)

Collapse
 
aacore profile image
Aaron

thanks. that's great.

Collapse
 
b0ndarenk07 profile image
Vlad

worked for me

Collapse
 
devspac3 profile image
Uzay Kaya

Tesekkurler Hasan,

export PATH="${HOME}/.pyenv/shims:${PATH}" bu adim icin zshrc'ye eklenmesi gerektigini belirten bir aciklama eklenebilir