下载spark 1.5.0预建并通过pyspark运行这个简单的代码
from pyspark.sql import Row
l = [('Alice', 1)]
sqlContext.createDataFrame(l).collect
收益率错误:
15/09/30 06:48:48 INFO Datastore: The class "org.apache.hadoop.hive.metastore.model.MResourceUri" is tagged as "embedded-only" so do
es not have its own datastore table.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\bigdata\spark-1.5\spark-1.5.0\python\pyspark\sql\context.py", line 408, in createDataFrame
jdf = self._ssql_ctx.applySchemaToPythonRDD(jrdd.rdd(), schema.json())
File "c:\bigdata\spark-1.5\spark-1.5.0\python\pyspark\sql\context.py", line 660, in _ssql_ctx
"build/sbt assembly", e)
Exception: ("You must build Spark with Hive. Export 'SPARK_HIVE=true' and run build/sbt assembly", Py4JJavaError(u'An error occurred
while calling None.org.apache.spark.sql.hive.HiveContext.\n', JavaObject id=o28))
所以试着自己编译
c:\bigdata\spark-1.5\spark-1.5.0>.\build\apache-maven-3.3.3\bin\mvn -Phadoop-2.4 -Dhadoop.version=2.4.0 -DskipTests -Phive -Phive-t
hriftserver clean package
但在编译版本上仍会出现相同的错误。
有什么建议吗?
答案 0 :(得分:1)
导入行
后添加这些行from pyspark import SparkContext
from pyspark.sql import SQLContext
sc = SparkContext( 'local', 'pyspark')
sqlContext = SQLContext(sc)