DEV Community

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

Posted on β€’ Edited on

43 2 2

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:

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

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

πŸ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay