SystemLink

cancel
Showing results for 
Search instead for 
Did you mean: 

Add R Kernel to SystemLink Jupyter

I would like to know if it is possible to add the R kernel to SystemLink Jupyter. Looking at the documentation for JupyterLab, this looks rather easy: https://jupyterlab.readthedocs.io/en/latest/user/documents_kernels.html

 

Is this possible, and has anyone used R in SystemLink Jupyter?

 

I have developed some R Scripts in R Studio and am wondering if I might be able to migrate them into Jupyter on my SystemLink Server to potentially automate the process and allow the data to be easily viewed.

Thank you

Chase Fearing
Test Engineer, Certified LabVIEW Architect
0 Kudos
Message 1 of 5
(161 Views)
Highlighted

Give this a try.

 

  • R uses TEMP, which is not currently set on the environment spawned by Jupyter, to set TEMP change line 31 of C:\Program Files\National Instruments\Shared\Skyline\Python\3.7\Lib\site-packages\winlocalprocessspawner\winlocalprocessspawner.py from:
    • win_env_keep = ['SYSTEMROOT', 'APPDATA', 'WINDIR', 'USERPROFILE']         to
    • win_env_keep = ['SYSTEMROOT', 'APPDATA', 'WINDIR', 'USERPROFILE', 'TEMP']
  • 2) Install R, if not already installed: https://www.r-project.org/
  • 3) From an R console running as Admin (it is crucial to run as Admin, as we need the IRKernel installed for all users)
       2.1) Install IRKernel:
            install.packages('IRkernel') 
       2.2) Make the kernel available to SystemLink Jupyter installation (adjust the path under prefix as needed)
            IRkernel::installspec(user = FALSE, prefix = '"C:/Program\ Files/National\ Instruments/Shared/Skyline/Python/3.7"')
0 Kudos
Message 2 of 5
(94 Views)

Thanks Josh, I was able to get to step 3.1, but could not complete 3.2. Although running the R console did not install IRkernel for all users. I had to specify the lib:

 

install.packages("IRkernel", lib="C:\Program Files\R\R-3.6.1\library")

 

When I run IRkernel::spec I get the following error:

jupyter-client has to be installed but "jupyter kernelspec --version" exited with code 127. In addition: Warning message: In system2("jupyter", c("kernelspec", "--version"), FALSE, FALSE) : '"jupyter"' not found

Chase Fearing
Test Engineer, Certified LabVIEW Architect
0 Kudos
Message 3 of 5
(45 Views)

Hi, 

 

I believe the problem might be that jupyter-kernelspec.exe is not being found. As a workaround, could you try to use setwd from the R console to set the current directory to "c:\Program Files\National Instruments\Shared\Skyline\Python\3.7\Scripts" before running step 3.2?

0 Kudos
Message 4 of 5
(30 Views)

That did the trick! Let me document the steps I took in case anyone else comes along

 

  1. R uses TEMP, which is not currently set on the environment spawned by Jupyter, to set TEMP change line 31 of C:\Program Files\National Instruments\Shared\Skyline\Python\3.7\Lib\site-packages\winlocalprocessspawner\winlocalprocessspawner.py from:
    win_env_keep = ['SYSTEMROOT', 'APPDATA', 'WINDIR', 'USERPROFILE'] to
    win_env_keep = ['SYSTEMROOT', 'APPDATA', 'WINDIR', 'USERPROFILE', 'TEMP']
  2. Install R, if not already installed: https://www.r-project.org/ (I used R-3.6.1)
  3. Navigate to C:\Program Files\R\R-3.6.1\bin
  4. Right click R.exe and run as administrator - Opens an R Console
  5. Install IRkernel (define lib to install for all users)
  6. install.packages("IRkernel", lib="C:/Program Files/R/R-3.6.1/library")
  7. You will be prompted to select a CRAN mirror. I chose USA (CA)
  8. Load IRkernel library
  9. library(IRkernel)
  10. Set working directory
  11. setwd('c:/program files/national instruments/shared/skyline/python/3.7/scripts')
  12. Install Kernel
  13. IRkernel::installspec(user=FALSE, prefix='"c:/program files/national instruments/shared/skyline/python/3.7"')
  14. Launch SystemLink Jupyter Notebook. You should now see the R Kernel appear in the launcher
Chase Fearing
Test Engineer, Certified LabVIEW Architect
0 Kudos
Message 5 of 5
(24 Views)