R cannot be initialized

Hi,

I am encountering the above error in Knime when trying to use the R nodes.

I think I have all the necessary packages installed in R and in Knime.

This is what I can see in the log:

R Output Reader : RBinUtil : : : External Rscript process output:
R Error Reader : RBinUtil : : : External Rscript process error output:

Does anyone have a solution? I am running 3.7.1.

Thanks

Hi there!

Welcome to KNIME community!

There is a great topic regarding installing and running R with KNIME so check it out :wink:

Br,
Ivan

2 Likes

Thanks,

I have gone through through that guide and the linked posts as well, I can’t find the issue though.

I have the latest version of Rserve and Cairo installed, I have uninstalled and reinstalled the Knime packages for R as well. I am running Windows 10 64 bit. I am able to get some of the community R nodes to work by starting Rserve in Rstudio, however the nodes hang at ‘Executing - Transfer to R’ for anything other than very basic scripts. The R nodes from Knime won’t run at all due to the ‘R cannot be initialized error’.

Maybe you could construct a small example and try to run it with the generic R nodes of KNIME. You could clear your log file before and then post this log file here so we might have a look about what is going on.

And maybe you could post a screenshot of your KNIME settings as well. And also you might post the small test workflow you are using so we see if there are any hints. How large is the initial file?

Typical additional culprits - besides the initial setup (which in most cases is the problem):

  • very complex paths with special characters
  • no rights to write in certain areas
  • virus scanners
  • virtual hard drives and slow network IO
  • several processes trying to access R at once

I have attached the log and an example workflow, it’s just an R snippet node.
Which settings would you like to see?

Thanks
knime.log (393.4 KB)
R Example.knwf (5.1 KB)

There is one line in the log file that hints to some strange configuration of the RServe.exe. It could have to do with the path where R stores its libraries/packages.

Caused by: java.io.IOException: Command not found: \/Users$/JamesOllier/Documents/R/win-library/3.5/Rserve\libs\x64\Rserve.exe

Maybe you could run

.libPaths()

The you could check which version of RServe you have running

packageVersion("Rserve")

and see if there is more than one.
You could show us your R settings like this (screenshot is from a Mac):

Hi,

This is what I see running those commands:

.libPaths()
[1] “/Users$/JamesOllier/Documents/R/win-library/3.5” “C:/Program Files/R/R-3.5.2/library”
packageVersion(“Rserve”)
[1] ‘1.8.6’

These are my R settings in Knime:

Thanks

At a first glance the settings look good but this part worries me and may have to do with the problem - also the log file hints in that direction.

/Users$/ for me does not look like a valid path and I am not sure if you can access this directory. And also the question is if the Rserve is stored there or in the other location.

Could you check out what is going on with this path and if you are able to remove it. I have to look up how to handle that.

2 Likes

For anyone else encountering this problem (“R cannot be initialized”), it certainly can be related to the path name where Rserve is installed.

I am using KNIME 4.1.0 with R 3.6 on Windows 10 64-bit.
I don’t have access to write to the C:/ drive and use a mapped drive to host my packages. I got the same error as @JamesOllier in java (Caused by: java.io.IOException: Command not found: path-to-Rserve\Rserve.exe). Even though I changed my .libPaths() in R to direct to a path such as “D:/path-to-win-library/” and installed Rserve to that library, KNIME tried to load Rserve using the server name (e.g. \\server), since the server name uses backslashes, it need multiple escape slashes, however only one backslash was loaded as the server path name (e.g. \server\path-to-Rserve\Rserve.exe instead of \\server\path-to-Rserve\Rserve.exe) and therefore the Rserve.exe file could not be loaded.

For me the solution was to get access to place Rserve in my library folder under the R installation (on the C:/ drive).

2 Likes

Hi there @alexga,

tnx for chipping in with nice explanation and your solution! And welcome to community :wink:

Br,
Ivan

I am having the same issue. I have tried nearly everything I have seen online.

After changing .libpaths() to
.libPaths()
[1] “C:/Program Files/Microsoft/R Client/R-4.0.2/library”

install.packages(“Rserve”)

trying URL ‘https://cran.rstudio.com/bin/windows/contrib/4.0/Rserve_1.7-3.1.zip
Content type ‘application/zip’ length 990697 bytes (967 KB)
downloaded 967 KB

package ‘Rserve’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\nzr\AppData\Local\Temp\RtmpaEl0Z6\downloaded_packages

Although it installs, I keep getting the error message that R cannot be initialized when I am trying to use the R readxls node in Knime.

This is the first time I try using an R node, and I know almost nothing about R other than the fact that a node exists that can read a large xlsx file so I can take that table and write it to SQL Db. Any help with this would be stellar.

@noemireyes since problems about KNIME and R occur on a frequent basis I have compiled a collection about documentations and additional things you will most likely have to try. You will have to comile RServe 1.8.6 on your machine and use RTools to do that. You will find the necessary links here:

3 Likes

Hi @mlauber71, I have gone through the full guide and have tried all of these steps and still get the following error message.
ERROR R Source (Table) 0:84 Execute failed: Exception occurred during R initialization.
I am running R 4.0.2 with Windows 64 bit and KNIME 4.2.1 rServe is 1.8.7 ( and has been verified in R) the library has also been transferred over. The default R location is set in KNIME, and when I try using any R node, I get the same error.

Here is the logcopy of KNIME log.txt (3.8 KB)

Thanks again for your help,
Noemi

@noemireyes could you try to run this workflow and see what the results are.

Have you checked what the settings are in the KNIME preferences. Are there any error messages?

Then the passages in the Log about WindowsDefenderExceptionHandler sound ominous. Could it be that you experience problems with a virus scanner?

And is your R and KNIME on a local installation/machine or maybe on some remote or virtual drive.

Then you could check if you could start and stop RServe outside KNIME from RStudio for example. This would be used with the R community nodes, but just to make sure.

1 Like

I tried so much of what you shared. Thank you @mlauber71!
I ended up uninstalling R, R Studio, Rtools, and KNIME. I followed the install instructions once again ( making sure I was doing so as an administrator) and immediately saw a change in the error messages.

One thing I did differently this time is selecting the options to only install only the 64bit versions. The other strategy was to run R & R Studio as an administrator and changing the library paths to the R home folder before installing any packages.

After Compiling Rserve using @mattflor’s instructions, I loaded Rserve. It took some time to figure out there are a few steps to run before I start working in KNIME and I found that here , this turned out to be a critical step for me. I was able to run the workflow you linked above and I also ran the R_Intro_1 workflow (Intro_to_R_in_Knime). This workflow requires additional packages to be installed and once they were installed, I got green lights all the way!

I am fairly new to KNIME and a newbie to R, so this was definitely an exercise in patience over many days… 7 DAYS! Sticking with it was rewarding. I really hope this helps future learners.
Thanks again for your help with this matter.

Best wishes,
NR

5 Likes

Glad it worked in the end. That is my experience with a lot of things concerning data analytical problems. You have to stick to it and be relentless until you achieve victory :slight_smile:

Your observations with the Paths and the admin rights and so on is very interesting. I will include them in the collection.

3 Likes

One of my teammate also faced the same issue of R not initialized, she has missed to install additional packages like Rtools, RServe, etc. I remember when i had the same issue, i gone through the forum and found very useful posts from others, especially @mlauber71 (thank you so much for this) and with my experience i was able to guide her and succeeded.

Regards,
Pavan

4 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.