0

我正在尝试使用 spark graphframe 创建图形

这是代码:

import org.graphframes._

// Node DataFrames
val v = sqlContext.createDataFrame(List(
  ("a", "Alice", 34),
  ("b", "Bob", 36),
  ("c", "Charlie", 30),
  ("d", "David", 29),
  ("e", "Esther", 32),
  ("f", "Fanny", 36),
  ("g", "Gabby", 60)
)).toDF("id", "name", "age")

// Edge DataFrame
val e = sqlContext.createDataFrame(List(
  ("a", "b", "friend"),
  ("b", "c", "follow"),
  ("c", "b", "follow"),
  ("f", "c", "follow"),
  ("e", "f", "follow"),
  ("e", "d", "friend"),
  ("d", "a", "friend"),
  ("a", "e", "friend")
)).toDF("src", "dst", "relationship")

// Create a GraphFrame
val g = GraphFrame(v, e)

但这是我得到的错误:

错误:加载类文件“GraphFrame.class”时检测到缺少或无效的依赖项。无法访问包 org.apache.spark 中的类型 Logging,因为它(或其依赖项)丢失。检查您的构建定义是否存在缺失或冲突的依赖项。(重新运行-Ylog-classpath以查看有问题的类路径。)如果“GraphFrame.class”是针对不兼容的 org.apache.spark 版本编译的,则完全重建可能会有所帮助。

我正在使用 Apache Spark 2.1 和 Scala 2.11。任何建议可能是什么问题?

4

1 回答 1

0

从 maven 中央仓库下载以下软件包

com.typesafe.scala-logging_scala-logging-api_2.11-2.1.2.jar    
graphframes_graphframes-0.5.0-spark2.1-s_2.11.jar  
org.slf4j_slf4j-api-1.7.7.jar
com.typesafe.scala-logging_scala-logging-slf4j_2.11-2.1.2.jar  
org.scala-lang_scala-reflect-2.11.0.jar

将以下内容添加到您的 sparks-default.conf 文件中(上述下载的 jar 所在的绝对路径的逗号分隔列表)

spark.jars            path_2_jar/org.slf4j_slf4j-api-1.7.7.jar, path_2_jar/org.scala-lang_scala-reflect-2.11.0.jar, path_2_jar/graphframes_graphframes-0.5.0-spark2.1-s_2.11.jar, path_2_jar/com.typesafe.scala-logging_scala-logging-slf4j_2.11-2.1.2.jar, path_2_jar/com.typesafe.scala-logging_scala-logging-api_2.11-2.1.2.jar
于 2017-09-11T12:02:19.710 回答