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<span>'t find Python executable "python", you can set the PYTHON env variable. </span>
Error: Can<span>'t find Python executable "python", you can set the PYTHON env variable. </span>
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 <span>install </span>pyenv
brew <span>install </span>pyenv
brew install pyenv

Enter fullscreen mode Exit fullscreen mode

2- Install the “2.7.18” version of python

pyenv <span>install </span>2.7.18
pyenv <span>install </span>2.7.18
pyenv install 2.7.18

Enter fullscreen mode Exit fullscreen mode

and set it as a global

pyenv global 2.7.18
pyenv global 2.7.18
pyenv global 2.7.18

Enter fullscreen mode Exit fullscreen mode

3- Add python executable directory to PATH

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

Enter fullscreen mode Exit fullscreen mode

You can check the PATHs with;

<span>echo</span> <span>$PATH</span>
<span>echo</span> <span>$PATH</span>
echo $PATH

Enter fullscreen mode Exit fullscreen mode

4- Add python executable directory to the .npmrc

npm config <span>set </span>python <span>$(</span>which python<span>)</span>
npm config <span>set </span>python <span>$(</span>which python<span>)</span>
npm config set python $(which python)

Enter fullscreen mode Exit fullscreen mode

You can check the config with

npm config list
npm config list 
npm config list

Enter fullscreen mode Exit fullscreen mode

or check from .npmrc;

<span>cat</span> .npmrc
<span>cat</span> .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 分享
Worrying does not empty tomorrow of its troubles, it empties today of its strength.
担忧不会清空明日的烦恼,它只会丧失今日的勇气
评论 抢沙发

请登录后发表评论

    暂无评论内容