Can't get spark to start - apache-spark

I have successfully installed and run apache spark in the past on my machine. Today I returned to it and tried to run it using : bin/spark-shell in the spark directory (bin file exists in this dir) but I am getting:
bin is not recognized as an internal or external command,
operable program or batch file.
It s running on windows 10 cmd shell, in case this is helpful. What could cause this?

I belive we need more info, to be able to answr your question.
Using './' specifies a path, starting in the root of your working directory. (Bash or powershell)
Are you running this in the cmd shell/powershell/bash shell?
What directory are you working in, when trying to execute your command?
Is there a bin folder in your current directory? (LS command or dir command)

JAVA_HOME was outdated... I had updated java without updating the path! That was the problem.

Check version of java installed and location where environment variable JAVA_HOME is pointing to.
In my case JAVA_HOME = C:\Program Files\Java\jdk1.7.0_79 (this is old version)
The cause of this issue was that I installed a new version of JDK and removed the previous installation but JAVA_HOME was pointing to the old environment which was missing.

Related

Netbeans 12 on Windows won't let me connect Tomcat

No matter which tutorial I follow, I am unable to get apache-tomcat-8.0.9 to work with Netbeans 12. The IDE keeps showing the error message The specified Server Location (Catalina Home) folder is not valid. I'm using jdk-14.0.1 and apache-ant-1.9.15.
The error:
My Catalina home directory C:\Program Files\apache-tomcat-8.0.9
Perhaps this error testing tomcat from the command line has some clues?
Based on the last link from the question try this:
In file nbproject/project.properties try to change this line (it may contains other path)
endorsed.classpath=\
${libs.javaee-endorsed-api-7.0.classpath}
to this:
endorsed.classpath=
I had the same problem and I fixed it by created CATALINA_HOME environment variable. For creating CATALINA_HOME in environment variable specify the path of catalina.bat file in tomcat folder installation without bin folder.
Ex: if you have catalina.bat in C:\Program Files\Apache\Tomcat\bin\catalina.bat, then specify in CATALINA_HOME just C:\Program Files\Apache\Tomcat as path.
I solved it in this way:
Go to the folder of Tomcat and enter, the system tells me that I don't have rigths, and if I want enter? I select yes. The system displays the content of the folder. I try again to conect netbeas with tomcat and now it works.

spark-submit won't work anywhere in cmd

I am trying to run spark-submit command from drive/folder where my python script and dataset is H:\spark_material. It just won't work !
But if I copy my python script into this folder C:\spark\bin then it works.
I believe it has something to do with environment variables.
Here is my Path = %JAVA_HOME%\bin; %SPARK_HOME%\bin
Here are my variables:
HADOOP_HOME = C:\winutils
JAVA_HOME = C:\jdk
SPARK_HOME = C:\spark
Java is properly installed as I have tried typing "java -version" anywhere in CMD and it works!!
Open your cmd and type path and check is apache spark path specify till bin folder
If not please fix your path
It was/is mystery - I re-installed everything one by one on my machine except operating system and it was an issue with Python distribution in my opinion. When I reinstalled Canopy(enthought), spark-submit command started to work. I still don't know why it happened as even in my previous version of Canopy (Python) was working fine properly.
Thank you everyone for your response and contribution. Learnt a lot from you guys.

install SPARK 2.1.1 on Windows 10

I want to install Spark 2.1.1 on windows 10, I used a step by step guide mentioned in http://www.eaiesb.com/blogs/?p=334
I did all the steps, but when I come to the last part where I should run the spark-shell and I get the following:
C:\>”spark\spark-2.1.1-bin-hadoop2.7\bin\spark-shell”
I keep getting this
The system cannot find the path specified.
I am running this on Windows 10 machine on a virtual box.
I didn’t have another partition (D is used in the site) so I set it to C:\spark where everything is there (i.e. Hadoop, Spark, and the tmp folders).
UPDATE:/// I reinstalled Java and selected another folder with no spaces within its name, The message that am getting now is (The system cannot find the path specified)
The environment variables are :
JAVA_HOME ——> C:\Java8\jdk1.8.0_131
HADOOP_HOME —–> C:\spark\Hadoop
SPARK_HOME —-> C:\spark\spark-2.1.1-bin-hadoop2.7
You Have TO Set Jdk > BinDir Path Like This :
JAVA_HOME ——> C:\Program Files\Java\jdk1.8.0_131\bin
NOTE: If You Set Another Path of File ENV Then You Have TO separate It using Semicolon ;
Example:
JAVA_HOME ——> C:\Program Files\Java\jdk1.8.0_131\bin;C:\Program Files\nodejs
Well, before anything, thanks for #RïshïKêsh Kümar on your comments I really appreciate you tried to help me out.
The problem was with Java path, the "location_of_java_folder" didn't work for me, So I just named a folder java8 and reinstalled java in that location,
oh, and don' forget to restart your machine for changes to take effect.

Spark on windows 10 not working

Im trying to get spark working on win10. When i try to run spark shell i get this error :
'Spark\spark-2.0.0-bin-hadoop2.7\bin..\jars""\ is not recognized as an internal or external command,operable program or batch file.
Failed to find Spark jars directory. You need to build Spark before running this program.
I am using a pre-built spark for hadoop 2.7 or later. I have installed java 8, eclipse neon, python 2.7, scala 2.11, gotten winutils for hadoop 2.7.1 And i still get this error.
When I donwloaded spark it comes in the tgz, when extracted there is another tzg inside, so i extracted it also and then I got all the bin folders and stuff. I need to access spark-shell. Can anyone help?
EDIT:
Solution i ended up using:
1) Virtual box
2) Linux mint
I got the same error while building Spark. You can move the extracted folder to C:\
Refer this:
http://techgobi.blogspot.in/2016/08/configure-spark-on-windows-some-error.html
You are probably giving the wrong folder path to Spark bin.
Just open the command prompt and change directory to the bin inside the spark folder.
Type spark-shell to check.
Refer: Spark on win 10
"On Windows, I found that if it is installed in a directory that has a space in the path (C:\Program Files\Spark) the installation will fail. Move it to the root or another directory with no spaces."
OR
If you have installed Spark under “C:\Program Files (x86)..” replace 'Program Files (x86)' with Progra~2 in the PATH env variable and SPARK_HOME user variable.

Why does spark-submit and spark-shell fail with "Failed to find Spark assembly JAR. You need to build Spark before running this program."?

I was trying to run spark-submit and I get
"Failed to find Spark assembly JAR.
You need to build Spark before running this program."
When I try to run spark-shell I get the same error.
What I have to do in this situation.
On Windows, I found that if it is installed in a directory that has a space in the path (C:\Program Files\Spark) the installation will fail. Move it to the root or another directory with no spaces.
Your Spark package doesn't include compiled Spark code. That's why you got the error message from these scripts spark-submit and spark-shell.
You have to download one of pre-built version in "Choose a package type" section from the Spark download page.
Try running mvn -DskipTests clean package first to build Spark.
If your spark binaries are in a folder where the name of the folder has spaces (for example, "Program Files (x86)"), it didn't work. I changed it to "Program_Files", then the spark_shell command works in cmd.
In my case, I install spark by pip3 install pyspark on macOS system, and the error caused by incorrect SPARK_HOME variable. It works when I run command like below:
PYSPARK_PYTHON=python3 SPARK_HOME=/usr/local/lib/python3.7/site-packages/pyspark python3 wordcount.py a.txt
Go to SPARK_HOME. Note that your SPARK_HOME variable should not include /bin at the end. Mention it when you're when you're adding it to path like this: export PATH=$SPARK_HOME/bin:$PATH
Run export MAVEN_OPTS="-Xmx2g -XX:ReservedCodeCacheSize=1g" to allot more memory to maven.
Run ./build/mvn -DskipTests clean package and be patient. It took my system 1 hour and 17 minutes to finish this.
Run ./dev/make-distribution.sh --name custom-spark --pip. This is just for python/pyspark. You can add more flags for Hive, Kubernetes, etc.
Running pyspark or spark-shell will now start pyspark and spark respectively.
If you have downloaded binary and getting this exception
Then please check your Spark_home path may contain spaces like "apache spark"/bin
Just remove spaces will works.
Just to add to #jurban1997 answer.
If you are running windows then make sure that SPARK_HOME and SCALA_HOME environment variables are setup right. SPARK_HOME should be pointing to {SPARK_HOME}\bin\spark-shell.cmd
For Windows machine with the pre-build version as of today (21.01.2022):
In order to verify all the edge cases you may have and avoid tedious guesswork about what exactly is not configred properly:
Find spark-class2.cmd and open it in with a text editor
Inspect the arguments of commands staring with call or if exists by typing the arguments in Command Prompt like this:
Open Command Prompt. (For PowerShell you need to print the var another way)
Copy-paste %SPARK_HOME%\bin\ as is and press enter.
If you see something like bin\bin in the path displayed now then you have appended /bin in your environment variable %SPARK_HOME%.
Now you have to add the path to the spark/bin to your PATH variable or it will not find spark-submit command
Try out and correct every path variable that the script in this file uses and and you should be good to go.
After that enter spark-submit ... you may now encounter the missing hadoop winutils.exe for which problem you can go get the tool and paste it where the spark-submit.cmd is located
Spark Installation:
For Window machine:
Download spark-2.1.1-bin-hadoop2.7.tgz from this site https://spark.apache.org/downloads.html
Unzip and Paste your spark folder in C:\ drive and set environment variable.
If you don’t have Hadoop,
you need to create Hadoop folder and also create Bin folder in it and then copy and paste winutils.exe file in it.
download winutils file from [https://codeload.github.com/gvreddy1210/64bit/zip/master][1]
and paste winutils.exe file in Hadoop\bin folder and set environment variable for c:\hadoop\bin;
create temp\hive folder in C:\ drive and give the full permission to this folder like:
C:\Windows\system32>C:\hadoop\bin\winutils.exe chmod 777 /tmp/hive
open command prompt first run C:\hadoop\bin> winutils.exe and then navigate to C:\spark\bin>
run spark-shell

Resources