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.

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

or check from .npmrc;



cat .npmrc


Enter fullscreen mode Exit fullscreen mode

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

Arrivederci


Source:

原文链接:Solution of “Can’t find Python executable ‘python'” Node Error

© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容