虽然,在 github 的源代码中我看到 pyspark.testing 模块存在,但是,我的本地环境抛出了找不到 pyspark.testing 的错误。
https://github.com/apache/spark/blob/master/python/pyspark/testing/sqlutils.py#L27 (源代码)
已安装 pyspark 作为 pip 安装 pyspark
conda环境下pyspark模块内部的文件夹结构:
d---- 6/2/2022 12:15 PM bin
d---- 6/2/2022 12:15 PM cloudpickle
d---- 6/2/2022 12:15 PM data
d---- 6/2/2022 12:15 PM examples
d---- 6/2/2022 12:15 PM jars
d---- 6/2/2022 12:15 PM licenses
d---- 6/2/2022 12:15 PM ml
d---- 6/2/2022 12:15 PM mllib
d---- 6/2/2022 12:15 PM pandas
d---- 6/2/2022 12:15 PM python
d---- 6/2/2022 12:15 PM resource
d---- 6/2/2022 12:15 PM sbin
d---- 6/2/2022 12:15 PM sql
d---- 6/2/2022 12:15 PM streaming
虽然 git repo 中的所有其他文件夹都存在,但是测试文件夹不存在。
安装的pyspark版本
pyspark==3.2.1
似乎仅在 PySpark 3.5.0 中添加了测试功能,请注意发行说明中的“PySpark 测试框架”https://spark.apache.org/releases/spark-release-3-5-0.html
尽管 pyspark 源代码中甚至在版本 3.5.0 之前就存在包“testing”,但在 PySpark 安装过程中被跳过,因为 setup.py 中未提及它。