Solving issue with python node.js npm – “Can’t find Python executable “python”, you can set the PYTHON env variable.”

Issue with python node.js npm – “Can’t find Python executable “python”, you can set the PYTHON env variable.” is an issue which occurs when you do not correctly add ;%PYTHON; to your PATH variable.

Today I will be explaining why this issue is taking place and how to solve it.

Exploring the issue with python node.js npm – “Can’t find Python executable “python”, you can set the PYTHON env variable.”

This is an issue which occurs when you do not correctly add ;%PYTHON; to your PATH variable.

Do not mix between issues. Make sure the message looks like the issue description bellow

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

Bellow is a number of tested methods that I have tried and that have worked for me.

Solution 1 : Correctly edit your PATH Variable and add ;%PYTHON; (After creating PythonPath )

The first solution is a step by step solution, so please make sure to not miss any steps.

Navigate to Computer Properties then navigate to Advanced System Settings and then click on environment variables.

The second step is to add the path to where you have installed python ( this is very important ). For example it could be.

                                                                       #
C:\Python27
# or
C:\Program Files\Python_2.7.10
                                                                       #

Then, create a Variable called PythonPath under system variables.

Then edit your PATH Variable and add ;%PYTHON; at the end.

So, instead of this

                                                                       #
C:\Python27
# or
C:\Program Files\Python_2.7.10
                                                                       #

It should look like this

                                                                       #
C:\Python27;%PYTHON;
# or this
C:\Program Files\Python_2.7.10;%PYTHON;
                                                                       #

Note : You can try all of this with your current version of Python. And if this does not work please Stick to the exact versions above ie. Python 2.7 or Python 2.7.10

Bellow, I have a different method. That might work for you if this one does not work.

Solution 2 : install python 2.7 and/or use npm to set the python path and/or install windows-build-tools

In this method I am going o present a couple of options that do not necessarily go together but each one of them could be enough to solve the issue depending on your particular case.

The first option is to uninstall your current version of Python and then install python 2.7 instead.

The second option is to open the command prompt as administrator and run the following command in order to install windows-build-tools.

                                                                       #
npm install -g windows-build-tools
                                                                       #

Alternatively, you can also use npm to set the python path

                                                                       #
npm config set python C:\Library\Python\Python27\python.exe
                                                                       #

It is not necessary to use all the options above at the same time but a little bit of troubleshooting goes a long way, in short combining the options above might solve the issue for you.

I hope the methods above have been helpful, I hope you solved the error already. Thank you for reading the entire blog post.

Summing-up : 

That’s it fellow developers, this is the end of this guide, I hope you found this useful in solving your particular issue, if you have the means and want to help, please support our work on our Kofi account.

Thank you for reading, keep coding and cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/