Installing a R on WinPython

824 views
Skip to first unread message

LucK

unread,
Oct 3, 2016, 5:52:27 PM10/3/16
to WinPython
Recently I installed 'WinPython-64bit-3.5.2.2Qt5' 
I followed the Jupyter Notebook 'installing_R.ipynb' and it seemed to proceed as expected. 
But when I restarted Jupyter, the R kernel wasn't there.

In the past I followed the same procedure for 'WinPython-64bit-3.4.4.1' without any problems.
I noticed that in the 'settings' folder the subfolder 'kernel' was missing.
Based on my older installation I copied the folder and files and changed the "kernel.json" file manually.
Everything seems to work fine. 

Afterwards I saw that the cell "# make RKernel a movable installation with the rest of WinPython" previously showed the message
"patching C:\WinPython\WinPython-64bit-3.4.4.1-R\settings\kernels\ir\kernel.json from C:/WinPython/WinPython-64bit-3.4.4.1-R to {prefix}/.."

What may cause this problem?

LucK

unread,
Oct 3, 2016, 6:28:02 PM10/3/16
to WinPython
It seems that the notebook 'installing_R' has changed.
I checked the output of the batch file 'R_launcher.bat' and noticed the following problem

* installing *source* package 'IRkernel' ...
** R
** inst
** tests
** preparing package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
  there is no package called 'stringr'
ERROR: lazy loading failed for package 'IRkernel'
* removing 'C:/WinPython/WinPython-Test/tools/R/library/IRkernel'
Error: Command failed (1)
Execution halted

I manually installed the package 'stringr' but that didn't resolve the problem because next I run into an error message regarding package 'rzmq'.

stonebig

unread,
Oct 4, 2016, 2:27:54 PM10/4/16
to WinPython
Hi Lu, 

You are right, something changed, maybe "IRkernel" requirements ...

... you need to change this cell of the notebook (no more 'rzmq', add 'stringr' and 'crayon') ;

import os
import sys
import io
# let's create a R launcher  
r_launcher = r"""
@echo off
call %~dp0env.bat
rscript %*
"""
r_launcher_bat = os.environ["WINPYDIR"]+"\\..\\scripts\\R_launcher.bat"
# let's create a R init script
# in manual command line, you can use repos = c('http://irkernel.github.io/', getOption('repos'))
r_initialization = r"""
install.packages(c('repr', 'IRdisplay', 'stringr', 'crayon', 'pbdZMQ', 'devtools'), repos = c('http://cran.rstudio.com/', 'http://cran.rstudio.com/'))
devtools::install_github('IRkernel/IRkernel')
library('pbdZMQ')
library('repr')
library('IRkernel')
library('IRdisplay')
library('crayon')
library('stringr')
IRkernel::installspec()
"""
r_initialization_r = os.path.normpath(os.environ["WINPYDIR"]+"\\..\\scripts\\R_initialization.r")

for i in [(r_launcher,r_launcher_bat), (r_initialization, r_initialization_r)]:
    with io.open(i[1], 'w', encoding = sys.getdefaultencoding() ) as f:
        for line in i[0].splitlines():
            f.write('%s\n' %  line  )


stonebig

unread,
Oct 4, 2016, 2:40:14 PM10/4/16
to WinPython
I notice also that "head('flights')" is uncorrect and should be "head(flights)" 

stonebig

unread,
Oct 4, 2016, 2:46:39 PM10/4/16
to WinPython

LucK

unread,
Oct 5, 2016, 8:20:53 AM10/5/16
to WinPython
Hi,
everything went well. thanks.
Luc
Reply all
Reply to author
Forward
0 new messages