Gopala
Gopala

Reputation: 10463

Pyspark (spark 1.6.x) ImportError: cannot import name Py4JJavaError

I am using Apache-Spark (pyspark) and everything works fine. Now, I am trying to load a data that may or may not exist. So, I am trying to catch the Py4JJavaError and am trying to import it as follows:

from py4j.java_gateway import Py4JJavaError
ImportError: cannot import name Py4JJavaError

When I unzip this file: /usr/local/Cellar/apache-spark/1.6.2/python/lib/py4j-0.9-src.zip

And inspect this file: java_gateway.py

I find no Py4JJavaError.

What am I doing wrong? Any other place / path I should be using instead?

Upvotes: 3

Views: 3057

Answers (1)

Matt Messersmith
Matt Messersmith

Reputation: 13747

Try from py4j.protocol import Py4JJavaError.

Upvotes: 12

Related Questions