Forum Discussion
Graphframes error: ClassNotFoundException
- 2 years ago
Anonymous : I received a message from your support engineer with the following solutions:
- Use Scala instead of Python:
- Add the library manually to the environment:
- Install the jar from maven repository. reference: Maven Repository: graphframes » graphframes » 0.8.0-spark3.0-s_2.12 (mvnrepository.com)
- upload the Jar to your environment. Reference: Library management in Fabric environments - Microsoft Fabric | Microsoft Learn
- Attach the environment to your workspace. Reference: Create, configure, and use an environment in Microsoft Fabric - Microsoft Fabric | Microsoft Learn
- Add this config as first cell inside your notebook:
%%configure -f { "conf": { "spark.jars.packages": "graphframes:graphframes:0.8.0-spark3.0-s_2.12" } }This solved the issue.
Thanks! Avi
Anonymous : I received a message from your support engineer with the following solutions:
- Use Scala instead of Python:
- Add the library manually to the environment:
- Install the jar from maven repository. reference: Maven Repository: graphframes » graphframes » 0.8.0-spark3.0-s_2.12 (mvnrepository.com)
- upload the Jar to your environment. Reference: Library management in Fabric environments - Microsoft Fabric | Microsoft Learn
- Attach the environment to your workspace. Reference: Create, configure, and use an environment in Microsoft Fabric - Microsoft Fabric | Microsoft Learn
- Add this config as first cell inside your notebook:
%%configure -f
{
"conf": {
"spark.jars.packages": "graphframes:graphframes:0.8.0-spark3.0-s_2.12"
}
}
This solved the issue.
Thanks! Avi
goreavin your suggested solution does work for me in a Fabric Notebook even using Python.
My custom environment uses Spark 3.5 and Scala 2.12, so:
- I downloaded graphframes-0.8.4-spark3.5-s_2.12.jar from https://spark-packages.org/package/graphframes/graphframes
- I imported it as Custom library in my custom environment.
- I attached this custom environment to my notebook workspace.
- I added as a first cell of my notebook:
%%configure
{
"conf": {
"spark.jars.packages": "graphframes:graphframes:0.8.4-spark3.5-s_2.12"
}
}- I added at the beginning of my PySpark cell:
from graphframes import GraphFrame
spark.sparkContext.setCheckpointDir("Files/graphframes_checkpoints")- and then I started working with graphframes in PySpark.
Note: setCheckpointDir is required by GraphFrame when calculating connected components. And the "Files/graphframes_checkpoints" path is relative to the default lakehouse path, so you need at least a default lakehouse attached to your notebook.
I can now survive in Fabric even without SQL Server's recursive CTE support. 😉