Let’s check out how the error shows up
How the error pops up
When you are trying to run the npm command on a project, it shows the error warning. You get this message:
Can’t find Python executable “python”, you can set the PYTHON env variable
You end up with an error warning when an application is unable to search the executable file of Python. Another reason for experiencing the error is the NPM and Node.js installation issue on windows.
How To Handle the Error “Can’t find Python executable “python”, you can set the PYTHON env variable”
We are bringing the best ways to solve the error warning exceptionally simple way. Check out them
Solution 1 – Specify the path
According to the error, you need to make sure the complete path of the file python.exe is added to the environment variable. If the application is unable to find the executable file of Python. You need to follow the below steps to specify the path in Windows:
- Click on the start menu and tap This PC, and click the last option Properties from that menu.
- Tap Advance system settings found in the sidebar
- Choose Environment Variables
- In the System variables section
- Tap Edit
- Add the path of Python to the list’s end, which separates by semicolons. For instance:
It can fix the error warning.
Solution 2 – Use windows-build-tools
To remove the error, you need to use windows-build-tools by Microsoft, which can install tools that are required. Type the below command in the command prompt:
npm install -g windows-build-tools
It also installs Python’s new version in a new environment. Using the ‘npm config’ command, you can configure Python executable path. Perhaps, it is an effective way in some scenarios. Use the following command:
npm config set python C:\Dir\Python\Python27\python.exe
Solution 3 – Updating and upgrading NPM
Another way to tackle the error warning is to update and upgrade NPM. It is as effective as the above solutions. To do NPM updating and upgrading, use the following command
sudo npm install npm@latest -g
We highlighted the solutions to help you make the error “Can’t find Python executable “python”, you can set the PYTHON env variable”. You can choose the solution as per the condition or status of your current project. Whenever you get this error, you can refer to this post.
I hope the solutions can help fix the error! I wish you happy coding!
If you need further assistance, you can write to us in the below comment box, and we will get back to us.