H2O Scala代码编译错误未找到对象AI

时间:2019-03-07 09:10:13

标签: scala apache-spark h2o

我正在尝试编译并运行简单的h2o scala代码。但是当我做sbt软件包时,我得到了错误。 我在sbt文件中丢失了什么吗?

这是我的h2o scala代码

import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
import org.apache.spark.sql._

import ai.h2o.automl.AutoML
import ai.h2o.automl.AutoMLBuildSpec

import org.apache.spark.h2o._

object H2oScalaEg1 {

  def main(args: Array[String]): Unit = {

  val sparkConf1 = new SparkConf().setMaster("local[2]").setAppName("H2oScalaEg1App")

  val sparkSession1 = SparkSession.builder.config(conf = sparkConf1).getOrCreate()

  val h2oContext = H2OContext.getOrCreate(sparkSession1.sparkContext)

  import h2oContext._

  import java.io.File

  import h2oContext.implicits._

  import water.Key

  }

}

这是我的sbt文件。

name := "H2oScalaEg1Name"

version := "1.0"

scalaVersion := "2.11.12"

scalaSource in Compile := baseDirectory.value / ""

libraryDependencies += "org.apache.spark" %% "spark-core" % "2.2.3"

libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.2.0"

libraryDependencies += "org.apache.spark" %% "spark-hive" % "2.2.0"

libraryDependencies += "ai.h2o" % "h2o-core" % "3.22.1.3" % "runtime" pomOnly()

当我执行sbt软件包时,出现这些错误

[error] /home/myuser1/h2oScalaEg1/H2oScalaEg1.scala:7:8: not found: object ai

[error] import ai.h2o.automl.AutoML

[error]        ^

[error] /home/myuser1/h2oScalaEg1/H2oScalaEg1.scala:8:8: not found: object ai

[error] import ai.h2o.automl.AutoMLBuildSpec

[error]        ^
[error] /home/myuser1/h2oScalaEg1/H2oScalaEg1.scala:10:25: object h2o is not a member of package org.apache.spark

[error] import org.apache.spark.h2o._
[error]                         ^

[error] /home/myuser1/h2oScalaEg1/H2oScalaEg1.scala:20:20: not found: value H2OContext
[error]   val h2oContext = H2OContext.getOrCreate(sparkSession1.sparkContext)
[error]                    ^


[error] /home/myuser1/h2oScalaEg1/H2oScalaEg1.scala:28:10: not found: value water
[error]   import water.Key
[error]          ^
[error] 5 errors found

如何解决此问题。

我的spark版本为spark-2.2.3-bin-hadoop2.7

谢谢

马瑞尔

1 个答案:

答案 0 :(得分:0)

pomOnly()中的

build.sbt向依赖关系管理处理程序指示,不应加载该依赖关系的jar库/工件,而只能查找元数据。

尝试改用libraryDependencies += "ai.h2o" % "h2o-core" % "3.22.1.3"

编辑1:另外,我认为您(至少)缺少一种库依赖项: libraryDependencies += "ai.h2o" % "h2o-automl" % "3.22.1.3"

请参阅:https://search.maven.org/artifact/ai.h2o/h2o-automl/3.22.1.5/pom

修改2: 您缺少的最后一个依赖项是气泡水核心: libraryDependencies += "ai.h2o" % "sparkling-water-core_2.11" % "2.4.6"应该可以解决问题。

这是sparkling-water/core/src/main/scala/org/apache/spark/h2o的github