Jupyter-Client Has to Be Installed But "Jupyter Kernelspec --Version" Exited with Code 127

jupyter-client has to be installed but “jupyter kernelspec --version” exited with code 127

Running this command from RStudio will show this error. When you run this command from command line/ terminal then everything will be fine.

So just type R from your command line.

Then Run below commands:

install.packages('devtools')

devtools::install_github('IRkernel/IRkernel')

Sample Image

IRkernel::installspec()

Cannot get IRkernel::installspec() to work, jupyter-client not visible

This answer is based on this by @Ryan, but since the question answered was actually about a Linux based system I put it here in a Windows question:

One way to overcome the problem - if adding PATH variables to the environment doesn't work - is the following:

  1. If Anaconda is installed and the Jupyter-Notebook with it (should be the standard install), open up the Anaconda prompt, not the Windows command prompt or the Anaconda Navigator
  2. Look up the executable of R (not Rgui or Rstudio), it should be somewhere like C:\Program Files\R\R-3.5.1\bin and copy the path
  3. Paste the path into the Anaconda prompt and start R by typing R
  4. Now execute IRkernel::installspec() once again, this time there shouldn't be an error
  5. Now you can start an R kernel within Jupyter-Notebook

In IRKernel::installspec(): jupyter kernelspec --version exits with code one

I posted the Error executing Jupyter command 'kernelspec' issue here:
Jupyter commands work only with a dash (e.g. jupyter-kernelspec instead of jupyter kernelspec)

To install the R Kernel, the workaround I used was to tweak the installspec function's code and execute this tweaked version locally.

The modification was to replace:

17: exit_code <- system2('jupyter', c('kernelspec', '--version'), FALSE, FALSE)
42: args <- c('kernelspec', 'install', '--replace', '--name', name, user_flag, prefix_flag, file.path(tmp_name, 'kernelspec'))
43: exit_code <- system2('jupyter', args)

By:

17: exit_code <- system2('jupyter-kernelspec', '--version', FALSE, FALSE)
42: args <- c('install', '--replace', '--name', name, user_flag, prefix_flag, file.path(tmp_name, 'kernelspec'))
43: exit_code <- system2('jupyter-kernelspec', args)

EDIT A better, simpler workaround here:
Jupyter commands work only with a dash (e.g. jupyter-kernelspec instead of jupyter kernelspec)

How to install Jupyter Lab/Notebook on Windows 10?

Please check if jupyter is in your user/system path. A quick way to check is by running jupyter in the command line, you could use powershell commandline:

Get-Command jupyter

CommandType Name Version Source
----------- ---- ------- ------
Application jupyter.exe 0.0.0.0 C:\Users\youruser\AppData\Local\Programs\...

If it's not there, then you can add to your system/user path and check with new instance of commandline again.

Error code 127 when adding R kernal to Jupyter Notebook

Ah I figured out what I needed to do. I'll leave an answer here in case anyone else has the same issue in the future.

Executing from either RStudio or R console wasn't working. Instead I had to run R in the anaconda console and then run the command and it worked without an error.



Related Topics



Leave a reply



Submit