我无法在 Jupyter 笔记本中的导入下运行。
findspark.init('home/ubuntu/spark-3.0.0-bin-hadoop3.2')
收到以下错误: ---------------------------------------------------------------------------
~/.local/lib/python3.6/site-packages/findspark.py in init(spark_home, python_path, edit_rc, edit_profile)
144 except IndexError:
145 raise Exception(
--> 146 "Unable to find py4j, your SPARK_HOME may not be configured correctly"
147 )
148 sys.path[:0] = [spark_python, py4j]
Exception: Unable to find py4j, your SPARK_HOME may not be configured correctly
我有 py4j 安装并尝试将以下这些行添加到 ~/.bashrcexport SPARK_HOME=/home/ubuntu/spark-3.0.0-bin-hadoop3.2
export PYTHONPATH=$SPARK_HOME/python/:$PYTHONPATH
export PYTHONPATH=$SPARK_HOME/python/lib/py4j-0.10.9-src.zip:$PYTHONPATH
最佳答案
检查您安装的 spark 版本是否与您在 SPARK_HOME 名称下声明的相同
例如(在 Google Colab 中),我安装了:
!wget -q https://downloads.apache.org/spark/spark-3.0.1/spark-3.0.1-bin-hadoop3.2.tgz
然后我声明:os.environ["SPARK_HOME"] = "/content/spark-3.0.1-bin-hadoop3.2"
看那个 spark-3.0.1-bin-hadoop3.2 两个地方必须相同
关于python - 错误 : Unable to find py4j, 您的 SPARK_HOME 可能未正确配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63572803/