1.使用findspark
- 安装spark
- 添加spark环境SPARK_HOME
- 安装findspark(pip install findspark)
- 使用
- import findspark
- findspark.init()
- from pyspark import SparkContext
- from pyspark import SparkConf
2.加载文件
- 导入os和sys
- 导入文件
- os.environ['SPARK_HOME'] = "E:\bigData\tar\spark-2.0.0-bin-hadoop2.7"
- sys.path.append("E:\bigData\tar\spark-2.0.0-bin-hadoop2.7/python")
- sys.path.append("E:\bigData\tar\spark-2.0.0-bin-hadoop2.7/python/lib/py4j-0.9-src.zip")
- from pyspark import SparkContext
- from pyspark import SparkConf