[英]Run script from within pyspark shell
I can run my python+pyspark script from the unix command line by typing 我可以通过以下命令从UNIX命令行运行python + pyspark脚本:
pyspark script.py
But how do I run script.py from within the pyspark shell? 但是,如何在pyspark shell中运行script.py? This seems like an elementary question but I can't find the answer anywhere. 这似乎是一个基本问题,但我找不到任何答案。 I tried 我试过了
execfile('script.py')
But I get an error which includes: 但是我收到一个错误,其中包括:
ValueError: Cannot run multiple SparkContexts at once
Could the error come from script.py
trying to create a new SparkContext variable? 错误可能来自script.py
尝试创建新的SparkContext变量吗?
When you launch the pyspark interactive client it usually says : SparkContext available as sc, HiveContext available as sqlContext.
当启动pyspark交互式客户端时,通常会说: SparkContext available as sc, HiveContext available as sqlContext.
If your script file contains sc = SparkContext()
, maybe try commenting it. 如果您的脚本文件包含sc = SparkContext()
,请尝试对其进行注释。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.