I'm trying to run a script in the pyspark environment but so far I haven't been able to. How can I run a script like python script.py but in pyspark? Thanks
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can do: ./bin/spark-submit mypythonfile.py
Running python applications through pyspark
is not supported as of Spark 2.0.
回答2:
pyspark 2.0 and later execute script file in environment variable PYTHONSTARTUP
, so you can run:
PYTHONSTARTUP=code.py pyspark
Compared to spark-submit
answer this is useful for running initialization code before using the interactive pyspark shell.
回答3:
Just spark-submit mypythonfile.py
should be enough.