How to fix spark-shell on Windows (fails with "was unexpected at this time")?

Viewed 18817

I am getting following error when running spark-shell command:

enter image description here

I have downloaded spark-2.1.1-bin-hadoop2.7.tgz file from http://spark.apache.org/downloads.html, extracted the tar file and pasted the contents of the folder into c:\Spark directory.

After that I have configured the environment variable for spark and jdk accordingly, but I am getting this error.

6 Answers

I resolved this error by using a short hand like "Progra~1" which is a short hand for "Program Files (x86)".

C:\Progra~1\Java\jdk1.8.0_161

You can see this issue when your Java home set like following in windows

JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_162\bin

Issue here is space in "Program Files (x86)" If you add double quotes will not work on window 10

"C:\Program Files (x86)\Java\jdk1.8.0_162\bin" 

You need to copy Java into outside Program Files (x86) then it should work

JAVA_HOME=C:\java\jdk1.8.0_171\bin

This error is due to the white spaces in the path of Spark and Java. You can remove the white spaces in path by using the shorthand method to write "Program Files" as "Progra~1". I had the same issue and it got resolved by above method.

Related