Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when initializing SparkContext in jupyterlab

Hi I'm trying to learn how to use pyspark but when I run this first line :

import pyspark
sc = pyspark.SparkContext('local[*]')

I get this error :

Py4JJavaError: An error occurred while calling None.org.apache.spark.api.java.JavaSparkContext.
: java.lang.IllegalAccessError: class org.apache.spark.storage.StorageUtils$ (in unnamed module @0x724b93a8) cannot access class sun.nio.ch.DirectBuffer (in module java.base) because module java.base does not export sun.nio.ch to unnamed module @0x724b93a8

I can't seem to find what's causing it :/

like image 206
The Questionner Avatar asked Sep 08 '26 15:09

The Questionner


1 Answers

Spark runs on Java 8/11, Scala 2.12, Python 3.6+ and R 3.5+. Python 3.6 support is deprecated as of Spark 3.2.0.

Java 8 prior to version 8u201 support is deprecated as of Spark 3.2.0

For the Scala API, Spark 3.2.0 uses Scala 2.12. You will need to use a compatible Scala version (2.12.x).

For Python 3.9, Arrow optimization and pandas UDFs might not work due to the supported Python versions in Apache Arrow. Please refer to the latest Python Compatibility page.

For Java 11, -Dio.netty.tryReflectionSetAccessible=true is required additionally for Apache Arrow library. This prevents java.lang.UnsupportedOperationException: sun.misc.Unsafe or java.nio.DirectByteBuffer.(long, int) not available when Apache Arrow uses Netty internally.

like image 68
JCompetence Avatar answered Sep 10 '26 05:09

JCompetence



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!