在spark上跑python腳本,需要指定python版本時,有如下做法:
方法一:
在環境變量文件 /etc/profile 中添加指定的pyspark,python的版本
export PYSPARK_PYTHON=指定的python路徑
export PYSPARK_DRIVER_PYTHON=指定的python路徑
保存后source一下 /etc/profile ,使之生效
方法二:
在spark-submit時增加參數 --conf spark.pyspark.python
和 --conf spark.pyspark.driver.python
spark-submit \ --driver-memory 5g --num-executors 5 --executor-cores 1 --executor-memory 1G --conf spark.pyspark.python=./.../bin/python --conf spark.pyspark.driver.python=./.../bin/python xx.py