scala 键入spark-shell时找不到spark submit

pu82cl6c  于 2023-06-23  发布在  Scala
关注(0)|答案(5)|浏览(267)

我一直在按照这个教程安装scala的spark:https://www.tutorialspoint.com/apache_spark/apache_spark_installation.htm
但是,当我尝试运行spark-shell时,我在控制台中收到此错误。

/usr/local/spark/bin/spark-shell: line 57: /usr/local/spark/bin/bin/spark-submit: No such file or directory

我的bashrc看起来像这样:

export PATH = $PATH:/usr/local/spark/bin
export SCALA_HOME=/usr/local/scala/bin
export PYTHONPATH=$SPARK_HOME/python

我哪里说错了?我以前安装过python的spark,但现在我尝试使用scala。斯巴克把变量搞混了吗?谢谢

mxg2im7a

mxg2im7a1#

在它搜索的路径中,bin过多:

/usr/local/spark/bin/bin/spark-submit

应该是

/usr/local/spark/bin/spark-submit

SPARK_HOME在您的情况下应该是/usr/local/spark/,而不是像现在这样的/usr/local/spark/bin/

zf2sa74q

zf2sa74q2#

基于@Wilmerton的回答,我在~/.bashrc中提出了以下工作配置:

# Apache Spark stuff
export JAVA_HOME=/usr/lib/jvm/default-java/jre
export SPARK_HOME=/usr/lib/spark
export SCALA_HOME=/usr/local/scala/bin
export PATH=$PATH:${SPARK_HOME}/bin
export PATH=$PATH:$SCALA_HOME

(我将default-jdkapt-get install default-jdkaptitude search jdk一起安装,产生了以下与p状态不同的条目:

i   default-jdk                                        - Standard Java or Java compatible Development Kit
i A default-jdk-headless                               - Standard Java or Java compatible Development Kit (headless)
i A openjdk-8-jdk                                      - OpenJDK Development Kit (JDK)
i A openjdk-8-jdk-headless                             - OpenJDK Development Kit (JDK) (headless)
iBA openjdk-8-jre                                      - OpenJDK Java runtime, using Hotspot JIT
i A openjdk-8-jre-headless                             - OpenJDK Java runtime, using Hotspot JIT (headless)
i   openjdk-9-jdk-headless                             - OpenJDK Development Kit (JDK) (headless)
iB  openjdk-9-jre                                      - OpenJDK Java runtime, using Hotspot JIT
i A openjdk-9-jre-headless                             - OpenJDK Java runtime, using Hotspot JIT (headless)

1l5u6lss

1l5u6lss3#

尝试将bashrc中的第二个环境变量更改为

export PATH=$PATH:/usr/local/scala/bin

我的.bash_profile和你的差不多,除了我用Path而不是SCALA_HOME

nukf8bse

nukf8bse4#

我也有同样的问题,我用这种方法解决了

!sudo apt update
!apt-get install openjdk-8-jdk-headless -qq > /dev/null
!wget -q https://dlcdn.apache.org/spark/spark-3.2.1/spark-3.2.1-bin-hadoop3.2.tgz
!tar xf spark-3.2.1-bin-hadoop3.2.tgz
!pip install -q findspark
!pip install pyspark

import os
os.environ["JAVA_HOME"] = "/usr/lib/jvm/java-8-openjdk-amd64"
os.environ["SPARK_HOME"] = "/content/spark-3.2.1-bin-hadoop3.2"

import findspark
findspark.init()
findspark.find()

from pyspark.sql import DataFrame, SparkSession
from typing import List
import pyspark.sql.types as T
import pyspark.sql.functions as F

spark = SparkSession \
       .builder \
       .appName("Our First Spark example") \
       .getOrCreate()

spark
8zzbczxx

8zzbczxx5#

也有同样的问题。在解压缩下载的spark包之后,必须创建一个名为SPARK_HOME的env变量,并将其设置为解压缩的spark包的路径。在我的例子中,我将这个env变量设置为解压缩包的父目录,而不是实际的包。因此,当执行spark-shell时,它无法找到执行命令的shell文件。
为了更好地说明问题,请在解压缩包后 checkout bin/spark-shell文件。在那里,您将发现代码中使用的${SPARK_HOME}

相关问题