Error can t find python executable python you can set the python env variable

When i install iconv with npm got the following error: iconv@2.1.0 install /root/Dropbox/nodeApps/nodeApp/node_modules/iconv node-gyp rebuild gyp ERR! configure error gyp ERR! stack Error: C...

When i install iconv with npm got the following error:

iconv@2.1.0 install /root/Dropbox/nodeApps/nodeApp/node_modules/iconv
node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:103:14)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:42:11
gyp ERR! stack     at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:43:25)
gyp ERR! stack     at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:46:29)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/which.js:57:16
gyp ERR! stack     at Object.oncomplete (fs.js:107:15)
gyp ERR! System Linux 3.8.0-19-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/Dropbox/nodeApps/nodeApp/node_modules/iconv
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok 

npm ERR! iconv@2.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the iconv@2.1.0 install script.
npm ERR! This is most likely a problem with the iconv package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls iconv
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.8.0-19-generic
npm ERR! command "node" "/usr/local/bin/npm" "i"
npm ERR! cwd /root/Dropbox/nodeApps/nodeApp
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.10
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /root/Dropbox/nodeApps/nodeApp/npm-debug.log
npm ERR! not ok code 0

although I installed python and can run it from console:

# python
Python 2.7.3 (default, May  9 2014, 12:18:32) 
[GCC 4.8.2] on linux2

and set up PATH in ~/.bashrc:

export PYTHONPATH=$PYTHONPATH:/Python-2.7.3
export PATH=$PATH:/Python-2.7.3

and done . ~/.bashrc

asked May 9, 2014 at 18:04

Maxim Yefremov's user avatar

Maxim YefremovMaxim Yefremov

13.3k25 gold badges116 silver badges162 bronze badges

2

For anyone encountering this issue on Ubuntu 16.04…
node-gyp can’t use Python 3.5.X which seems to the be the default that ships with 16.04. I read somewhere that 16.04 was supposed to ship with Python2 as well but I can’t find it on my install.

I fixed the above issue by:

apt-get update     
apt-get install python2.7    
ln -s /usr/bin/python2.7 /usr/bin/python 

Now when node-gyp goes looking for python it will hit your Python2.7 install and load correctly.

ern's user avatar

ern

1,52213 silver badges19 bronze badges

answered Apr 26, 2017 at 0:57

Chase's user avatar

3

In your bash session where you’re able to just type python and get a valid response, type in which python and note the full path location of the python binary. Take that location and put that into your PYTHONPATH and PATH environment variables, except without the python at the end.

For example, which python gives me:

/usr/local/bin/python

so I would write:

export PYTHONPATH=$PYTHONPATH:/usr/local/bin
export PATH=$PATH:/usr/local/bin

in my ~/.bashrc.

answered May 9, 2014 at 18:18

huu's user avatar

huuhuu

6,8022 gold badges33 silver badges49 bronze badges

2

There is a simple and safe way
Place this into ~/.bashrc or ~/.bash_aliases file:

alias python=python3

After adding the above in the file, run source ~/.bashrc or source ~/.bash_aliases

This solution worked for my Ubuntu
see the origin answer here

answered Mar 31, 2021 at 12:08

Kelei Ren's user avatar

Kelei RenKelei Ren

3214 silver badges9 bronze badges

Install python2.7.

apt install python2

answered Jun 1, 2021 at 12:24

Mohamed Gnedy's user avatar

2

the problem was because of ~/.bashrc was not loaded on ssh login. I put PATH vars to ~/.bash_profile and it’s ok

answered May 19, 2014 at 8:31

Maxim Yefremov's user avatar

Maxim YefremovMaxim Yefremov

13.3k25 gold badges116 silver badges162 bronze badges

Sometimes it is not only related to NPM. So, a system-wide solution is required. Then, just create a system-wide symlink for ‘python’ to your current python path.

For example, for my Ubuntu 20 setup (be root):

ln -s /usr/bin/python3 /usr/bin/python

Then verify the symlink:

ls -l /usr/bin/python
lrwxrwxrwx 1 root root 16 Feb 19 13:55 /usr/bin/python -> /usr/bin/python3

answered Feb 19, 2022 at 11:48

Faruk UNAL's user avatar

1

I had the same problem. You can solve it like this:

sudo apt install python2
npm config set python "/usr/bin/python2.7"

But if you don’t want to downgrade python3..

npm install -g node-gyp@latest
npm config set python "/usr/bin/python3.8"

answered Jun 3, 2022 at 8:38

이승현's user avatar

이승현이승현

812 silver badges9 bronze badges

To Solve Can’t find Python executable “python”, you can set the PYTHON env variable You need to set Python in the path variable OR you need to install windows-build-tools will resolve this error.

Contents

  1. How Can’t find Python executable «python», you can set the PYTHON env variable Error Occurs.
  2. Solution 1: Install windows-build-tools
  3. Solution 2: set PATH variable
  4. Solution 3: Just Run this command
  5. Frequently Asked Questions
  6. Conclusion

I am trying to NPM package but I am facing the following error in my terminal:

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

So here I am writing all the possible solutions that I have tried to resolve this error.

You need to install windows-build-tools and then Your error will be solved. Just run this command in your terminal.

npm i windows-build-tools

And Now, Your error will be solved. Thank You.

Note: Node.js now includes build tools for Windows. You probably no longer need a windows-build-tools tool.

Solution 2: set PATH variable

You just need to Install Python In Your Windows ( If Not Installed ) and then add python to your PATH variable. Using environment variable.

OR

You can set npm config set python path and it will also Solve your error. Just run this command in your terminal.

npm config set python E:Programm FilesPythonpython.exe

And Now, Your error must be solved.

Solution 3: Just Run this command

Open Your Cmd Using Admin Access And Run the following command.

npm install --global --production windows-build-tools

And now, Your error will be solved.

Frequently Asked Questions

  1. How To Solve Can’t find Python executable “python”, you can set the PYTHON env variable Error?

    To Solve Can’t find Python executable “python”, you can set the PYTHON env variable Error You just need to Install Python In Your Windows ( If Not Installed ) and then add python to your PATH variable. Using environment variable. OR You can set npm config set python path and it will also Solve your error. Just run this command in your terminal: npm config set python E:Programm FilesPythonpython.exe And Now, Your error must be solved.

  2. Can’t find Python executable “python”, you can set the PYTHON env variable

    To Solve Can’t find Python executable “python”, you can set the PYTHON env variable Error You need to install windows-build-tools and then Your error will be solved. Just run this command in your terminal: npm i windows-build-tools And Now, Your error will be solved. Thank You.

Conclusion

You need to set python.exe to the path variable and then your error will be solved. Hope Our article helped you to solve this error comment below which solution worked for you.

Also, Read

  • selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH
  • Error: This command is not available when running the Angular CLI outside a workspace
  • TypeError: cli.isMultipleCompiler is not a function
  • Cannot resolve No versions available for org.osgi.service:org.osgi.service.prefs:jar:[1.1.0,1.2.0) within specified range
  • ImportError: cannot import name ‘dtensor’ from ‘tensorflow.compat.v2.experimental’

Error: Can't Find Python Executable Python, You Can Set the PYTHON Env Variable

Every program consists of some variables and constant values. As the name suggests, we have environment variables that define the environment for some applications.

Several such variables are available, and we can also define our environment variables.

One such variable is PATH, which contains a list of directories containing all the executable files used to run some commands. Before using Python, we need to install it and add the directory of its executable to the PATH variable.

This ensures that we can run the Python command from the command prompt.

This tutorial will discuss the Can't find Python executable "python", you can set the PYTHON env variable error in Python and how to fix it.

the Error: Can't find Python executable "python", you can set the PYTHON env variable in Python

This error can persist when an application cannot find the location of the Python executable file. We need to ensure that the full path of the python.exe file has been added to the environment variable.

For Windows, we can check this by following the steps discussed below.

First, we must right-click This PC and select the Properties option from the menu. Then we need to go to the Advanced Settings menu and select Environment Variables.

This will take us to the Environment Variable screen, where we need to add the directory of the Python executable.

We need to add the directory to the PATH variable for the User. If the error persists, we can create a new variable named Python and add the directory here.

This should usually remove the discussed error.

Another common situation where this error can be expected is while installing Node.js and NPM on Windows. For such situations, there are further few more fixes that can help.

The first fix is using Microsoft windows-build-tools to install any required tools. We can use the following command in the command prompt.

npm install -g windows-build-tools

However, this will install some versions of Python in a new environment.

We can also configure the path of the Python executable with the npm config command. It can assist in some cases.

Use it as shown below.

npm config set python C:DirPythonPython27python.exe

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

Hasan TEZCAN

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:

  • https://github.com/TryGhost/node-sqlite3/issues/1552#issuecomment-1075059490

1. NPM error reporting

npm ERR! code 1
npm ERR! path D:WorkspacesWebstormProjectsshop-uibuyernode_modulesnode-sass
npm ERR! command failed
npm ERR! command C:Windowssystem32cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack     at PythonFinder.failNoPython (D:WorkspacesWebstormProjectsshop-uibuyernode_modulesnode-gyplibconfigure.js:484:19)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (D:WorkspacesWebstormProjectsshop-uibuyernode_modulesnode-gyplibconfigure.js:509:16)
npm ERR! gyp ERR! stack     at callback (D:WorkspacesWebstormProjectsshop-uibuyernode_modulesgraceful-fspolyfills.js:299:20)
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "D:\Program Files\nodejs\node.exe" "D:\Workspaces\WebstormProjects\shop-ui\buyer\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd D:WorkspacesWebstormProjectsshop-uibuyernode_modulesnode-sass
npm ERR! gyp ERR! node -v v16.13.2
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     D:Program Filesnodejsnode_cache_logs2022-01-28T09_54_16_535Z-debug.log

2. Solution
npm install --global --production windows-build-tools

Read More:

Понравилась статья? Поделить с друзьями:
  • Error can not get i2c device data
  • Error cameralist not match
  • Error calling startservicebyname
  • Error calling setupdigetdeviceregistrypropertyw 122 x360ce как исправить
  • Error calling python module function wbadmin testinstancesettingbyname