如何在 spark 中设置驱动程序的 python 版本? [英] How do I set the driver's python version in spark?
问题描述
我使用的是 spark 1.4.0-rc2,所以我可以将 python 3 与 spark 一起使用.如果我将 export PYSPARK_PYTHON=python3
添加到我的 .bashrc 文件中,我可以与 python 3 交互运行 spark.但是,如果我想在本地模式下运行独立程序,我会收到一个错误:>
I'm using spark 1.4.0-rc2 so I can use python 3 with spark. If I add export PYSPARK_PYTHON=python3
to my .bashrc file, I can run spark interactively with python 3. However, if I want to run a standalone program in local mode, I get an error:
Exception: Python in worker has different version 3.4 than that in driver 2.7, PySpark cannot run with different minor versions
如何为驱动程序指定python的版本?设置 export PYSPARK_DRIVER_PYTHON=python3
不起作用.
How can I specify the version of python for the driver? Setting export PYSPARK_DRIVER_PYTHON=python3
didn't work.
推荐答案
您需要确保您正在启动的独立项目是使用 Python 3 启动的.如果您通过 spark-submit 提交您的独立程序,那么它应该可以工作很好,但是如果您使用 python 启动它,请确保使用 python3 来启动您的应用程序.
You need to make sure the standalone project you're launching is launched with Python 3. If you are submitting your standalone program through spark-submit then it should work fine, but if you are launching it with python make sure you use python3 to start your app.
另外,确保你已经在 ./conf/spark-env.sh
中设置了你的 env 变量(如果它不存在你可以使用 spark-env.sh.template
作为基础.)
Also, make sure you have set your env variables in ./conf/spark-env.sh
(if it doesn't exist you can use spark-env.sh.template
as a base.)
这篇关于如何在 spark 中设置驱动程序的 python 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!