2

我已经安装了 Spark - 1.4.1(有 R 3.1.3 版本)。目前正在测试 SparkR 以运行统计模型。我能够运行一些示例代码,例如,

Sys.setenv(SAPRK_HOME = "C:\\hdp\\spark-1.4.1-bin-hadoop2.6")
.libPaths(c(file.path(Sys.getenv("SPARK_HOME"), "R", "lib"), .libPaths()))
#load the Sparkr library
library(SparkR)
# Create a spark context and a SQL context
sc <- sparkR.init(master = "local")

sqlContext <- sparkRSQL.init(sc)

#create a sparkR DataFrame
DF <- createDataFrame(sqlContext, faithful)

sparkR.stop()

所以接下来,我将rJava包安装到SparkR. 但它没有安装。给出以下错误。

> install.packages("rJava")
Installing package into 'C:/hdp/spark-1.4.1-bin-hadoop2.6/R/lib'
(as 'lib' is unspecified)
trying URL 'http://ftp.iitm.ac.in/cran/bin/windows/contrib/3.1/rJava_0.9-7.zip'
Content type 'text/html; charset="utf-8"' length 898 bytes
opened URL
downloaded 898 bytes

Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
  cannot open the connection
In addition: Warning messages:
1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
2: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
  cannot open compressed file 'rJava/DESCRIPTION', probable reason 'No such file or directory'

此外,当我SparkR在 shell 上运行命令时,它作为 32 位应用程序启动。我突出显示了版本信息,如下所示。 在此处输入图像描述

所以,请帮我解决这个问题。

4

2 回答 2

2

SparkRshell 中,它似乎改变了安装 R 包的位置。关键线是

Installing package into 'C:/hdp/spark-1.4.1-bin-hadoop2.6/R/lib'

我怀疑

  • 您没有“C:/hdp/spark-1.4.1-bin-hadoop2.6/R/lib”的写权限
  • 你一开始就不想把包裹放在那里。

你有两个选择,

  • 启动 vanilla R 会话并照常安装
  • 或者,使用lib参数 ininstall.packages指定要安装的位置rJava
于 2015-08-28T10:47:47.313 回答
0

我解决了这个问题。这是 R 版本问题,以前我使用的是 R 3.1.3。当时它给了我错误,rJava 包不适用于当前的 R 版本。

To solve I follow this steps:
1) Installed new R version i.e R 3.2.2
2) Then update the Path variable and new R version path(Windows -> "Path" -> "Edit environment variables to for your account" -> PATH -> edit the value.)
3) Again restart sparkR shell.

在此处输入图像描述

谢谢大家的支持!!!

于 2015-09-08T12:12:37.313 回答