Unable to run a basic GraphFrames example
<p>Trying to run a simple GraphFrame example using pyspark.</p>

<p>spark version : 2.0</p>

<p>graphframe version : 0.2.0</p>

<p>I am able to import graphframes in Jupyter:</p>

<pre><code>from graphframes import GraphFrame
GraphFrame
graphframes.graphframe.GraphFrame
</code></pre>

<p>I get this error when I try and create a GraphFrame object:</p>

<pre><code>---------------------------------------------------------------------------
Py4JJavaError                             Traceback (most recent call last)
&lt;ipython-input-23-2bf19c66804d&gt; in &lt;module&gt;()
----&gt; 1 gr_links = GraphFrame(df_web_page, df_parent_child_link)

/Users/roopal/software/graphframes-release-0.2.0/python/graphframes/graphframe.pyc in __init__(self, v, e)
     60         self._sc = self._sqlContext._sc
     61         self._sc._jvm.org.apache.spark.ml.feature.Tokenizer()
---&gt; 62         self._jvm_gf_api = _java_api(self._sc)
     63         self._jvm_graph = self._jvm_gf_api.createGraph(v._jdf, e._jdf)
     64 

/Users/roopal/software/graphframes-release-0.2.0/python/graphframes/graphframe.pyc in _java_api(jsc)
     32 def _java_api(jsc):
     33     javaClassName = "org.graphframes.GraphFramePythonAPI"
---&gt; 34     return jsc._jvm.Thread.currentThread().getContextClassLoader().loadClass(javaClassName) \
     35             .newInstance()
     36 

/Users/roopal/software/spark-2.0.0-bin-hadoop2.7/python/lib/py4j-0.10.1-src.zip/py4j/java_gateway.py in __call__(self, *args)
    931         answer = self.gateway_client.send_command(command)
    932         return_value = get_return_value(
--&gt; 933             answer, self.gateway_client, self.target_id, self.name)
    934 
    935         for temp_arg in temp_args:

/Users/roopal/software/spark-2.0.0-bin-hadoop2.7/python/pyspark/sql/utils.pyc in deco(*a, **kw)
     61     def deco(*a, **kw):
     62         try:
---&gt; 63             return f(*a, **kw)
     64         except py4j.protocol.Py4JJavaError as e:
     65             s = e.java_exception.toString()

/Users/roopal/software/spark-2.0.0-bin-hadoop2.7/python/lib/py4j-0.10.1-src.zip/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
    310                 raise Py4JJavaError(
    311                     "An error occurred while calling {0}{1}{2}.\n".
--&gt; 312                     format(target_id, ".", name), value)
    313             else:
    314                 raise Py4JError(

Py4JJavaError: An error occurred while calling o138.loadClass.
: java.lang.ClassNotFoundException: org.graphframes.GraphFramePythonAPI
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:237)
    at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
    at py4j.Gateway.invoke(Gateway.java:280)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:128)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:211)
    at java.lang.Thread.run(Thread.java:745)
</code></pre>

<p>The python code tries to read the java class (in the jar) I guess, but cant seem to find it.
Any suggestions how to fix this?</p>

<p>Make sure that your PYSPARK_SUBMIT_ARGS is updated to have "--packages graphframes:graphframes:0.2.0-spark2.0" in your kernel.json ~/.ipython/kernels//kernel.json.</p>

<p>You probably already looked at the following <a href="https://developer.ibm.com/clouddataservices/2016/07/15/intro-to-apache-spark-graphframes/" rel="nofollow">link</a>. It has more details on Jupiter setup. Basically, pyspark has to be supplied the graphframes.jar.</p>

python apache-spark pyspark jupyter graphframes