ModuleNotFoundError:没有名为"py4j"的模块 [英] ModuleNotFoundError: No module named 'py4j'
本文介绍了ModuleNotFoundError:没有名为"py4j"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我安装了Spark,但在将pyspark模块加载到ipython时遇到了问题.我收到以下错误:
I installed Spark and I am running into problems loading the pyspark module into ipython. I'm getting the following error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-49d7c4e178f8> in <module>
----> 1 import pyspark
/opt/spark/python/pyspark/__init__.py in <module>
44
45 from pyspark.conf import SparkConf
---> 46 from pyspark.context import SparkContext
47 from pyspark.rdd import RDD
48 from pyspark.files import SparkFiles
/opt/spark/python/pyspark/context.py in <module>
27 from tempfile import NamedTemporaryFile
28
---> 29 from py4j.protocol import Py4JError
30
31 from pyspark import accumulators
ModuleNotFoundError: No module named 'py4j'
推荐答案
如果可以直接运行spark,则可能必须修复环境变量PYTHONPATH
.检查目录$SPARK_HOME/python/lib/
中的文件名.如果是Spark版本2.4.3,则文件为py4j-0.10.7-src.zip
:
If you can run spark directly, maybe you have to fix the environment variable PYTHONPATH
. Check the filename in the directory $SPARK_HOME/python/lib/
. If the Spark version 2.4.3, the file is py4j-0.10.7-src.zip
:
export PYTHONPATH=$SPARK_HOME/python:$SPARK_HOME/python/lib/py4j-0.10.7-src.zip:$PYTHONPATH
这篇关于ModuleNotFoundError:没有名为"py4j"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文