Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

RuntimeError: Java gateway process exited before sending its port number after setting JAVA_HOME

I’m trying to start pyspark using VSCode but i am getting the follow errors:

Java not found and JAVA_HOME environment variable is not set.
Install Java and set JAVA_HOME to point to the Java installation directory.
Traceback (most recent call last):
  File "c:\Users\Erevos\Desktop\Pyspark\LearnSpark.py", line 5, in <module>
    spark = SparkSession.builder.appName("MyApp").getOrCreate()
  File "C:\Users\Erevos\AppData\Local\Programs\Python\Python310\lib\site-packages\pyspark\sql\session.py", line 477, in getOrCreate
    sc = SparkContext.getOrCreate(sparkConf)
  File "C:\Users\Erevos\AppData\Local\Programs\Python\Python310\lib\site-packages\pyspark\context.py", line 512, in getOrCreate
    SparkContext(conf=conf or SparkConf())
  File "C:\Users\Erevos\AppData\Local\Programs\Python\Python310\lib\site-packages\pyspark\context.py", line 198, in __init__
    SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
  File "C:\Users\Erevos\AppData\Local\Programs\Python\Python310\lib\site-packages\pyspark\context.py", line 432, in _ensure_initialized
    SparkContext._gateway = gateway or launch_gateway(conf)
  File "C:\Users\Erevos\AppData\Local\Programs\Python\Python310\lib\site-packages\pyspark\java_gateway.py", line 106, in launch_gateway
    raise RuntimeError("Java gateway process exited before sending its port number")
RuntimeError: Java gateway process exited before sending its port number

i have already set the JAVA_HOME = path, here

Moreover, i have downloaded the folders required: here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try to output the env variable

echo %JAVA_HOME%

and check if it’s correct.

If not correct check again your JAVA_HOME assignment.

Then, close and reopen the command prompt again that runs the java process (or the OS user session) and type java -version to check if it installed successfully.

If the java command fails follow this link.

Follow this link to have more info about JAVA_HOME.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading