Search code examples
rjupyter-notebookjupyterjupyter-irkernel

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


Trying to install the IRKernel for jupyter notebook, I am facing the following issue:

IRkernel::installspec()
# Results in
# Error in IRkernel::installspec() : 
# jupyter-client has to be installed but “jupyter kernelspec --version” exited with code 1.

This is related to the fact that on Windows, a dash is needed. Indeed, this doesn't work:

> jupyter kernelspec --version
Error executing Jupyter command 'kernelspec': [Errno 'jupyter-kernelspec' not found] 2

While this works:

> jupyter-kernelspec --version
5.2.2

Is there any way around this?

My OS is

> ver
Microsoft Windows [Version 10.0.16299.431]

And my sessionInfo():

R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C                   LC_TIME=French_France.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.16         digest_0.6.15        crayon_1.3.4         IRdisplay_0.5.0      repr_0.15.0         
 [6] jsonlite_1.5         magrittr_1.5         evaluate_0.10.1      stringi_1.1.7        uuid_0.1-2          
[11] rstudioapi_0.7       IRkernel_0.8.12.9000 tools_3.5.0          stringr_1.3.1        yaml_2.1.19         
[16] compiler_3.5.0       base64enc_0.1-3      pbdZMQ_0.3-3         htmltools_0.3.6     

Solution

  • 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)