ModuleNotFoundError: No module named 'py4j'

Jassim Elakrouch picture Jassim Elakrouch · May 28, 2019 · Viewed 8.6k times · Source

I installed Spark and I am running into problems loading the pyspark module into ipython. I'm getting the following error:

Answer

RayZen picture RayZen · Jul 30, 2019

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