macos 安装scala_如何在MacOS上安装Scala和Apache Spark

本文提供了在MacOS上安装Scala和Apache Spark的详细步骤,包括使用Homebrew安装Java、Scala、Spark,以及启动Spark Shell。通过遵循这些步骤,用户可以在自己的Mac上建立数据科学和机器学习的开发环境。
摘要由CSDN通过智能技术生成

macos 安装scala

by Jose Marcial Portilla

通过何塞·马西尔·波蒂利亚(Jose Marcial Portilla)

如何在MacOS上安装Scala和Apache Spark (How to Install Scala and Apache Spark on MacOS)

Here is a Step by Step guide to installing Scala and Apache Spark on MacOS.

这是在MacOS上安装Scala和Apache Spark的分步指南。

步骤1:自制软件 (Step 1: Get Homebrew)

Homebrew makes your life a lot easier when it comes to installing applications and languages on a Mac OS. You can get Homebrew by following the instructions on it’s website.

在Mac OS上安装应用程序和语言时,Homebrew使您的生活变得更加轻松。 您可以按照其网站上的说明获得Homebrew。

Which basically just tells you to open your terminal and type:

这基本上只是告诉您打开终端并输入:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

There are more detailed instructions on installing on the project’s GitHub page. Installing everything through Homebrew should automatically add all the appropriate PATH settings to your profile.

在项目的GitHub页面上有关于安装的更多详细说明 通过Homebrew安装所有内容后,应会自动将所有适当的PATH设置添加到您的配置文件中。

步骤2:安装xcode-select (Step 2: Installing xcode-select)

In order to install Java, Scala, and Spark through the command line we will probably need to install xcode-select and command line developer tools. Go to you terminal and type:

为了通过命令行安装Java,Scala和Spark,我们可能需要安装xcode-select和命令行开发人员工具。 在您的终端上输入:

xcode-select --install

You will get a prompt that looks something like this:

您将看到如下提示:

Go ahead and select install.

继续并选择安装。

步骤3:使用Homebrew安装Java (Step 3: Use Homebrew to install Java)

Scala is dependent on Java, you may or may not need to install it. The easiest way to install it is to just use HomeBrew:

Scala依赖于Java,您可能需要也可能不需要安装它。 安装它的最简单方法是只使用HomeBrew:

In your terminal type:

在您的终端中输入:

brew cask install java

You may need to enter your password at some point to complete the java installation. After running this Homebrew should have taken care of the Java install. Now we can move on to Scala.

您可能需要在某些时候输入密码才能完成Java安装。 运行此Homebrew之后,应该已经完成​​了Java安装。 现在我们可以转到Scala。

步骤4:使用Homebrew安装Scala (Step 4: Use Homebrew to install Scala)

Now with Homebrew installed go to your terminal and type:

现在安装好Homebrew后,转到终端并输入:

brew install scala
步骤5:使用Homebrew安装Apache Spark (Step 5: Use Homebrew to install Apache Spark)

Now with Scala installed go to your terminal and type:

现在安装了Scala后,转到您的终端并输入:

brew install apache-spark

Homebrew will now download and install Apache Spark, it may take some time depending on your internet connection.

Homebrew现在将下载并安装Apache Spark,这可能需要一些时间,具体取决于您的Internet连接。

步骤5:启动Spark Shell (Step 5: Start the Spark Shell)

Now try this command:

现在尝试以下命令:

spark-shell

You should see a flood of text and warnings but eventually see something like this:

您应该看到大量的文字和警告,但最终会看到类似以下的内容:

Welcome to      ____              __     / __/__  ___ _____/ /__    _\ \/ _ \/ _ `/ __/  '_/   /___/ .__/\_,_/_/ /_/\_\   version 2.0.1      /_/
Using Scala version 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_102)Type in expressions to have them evaluated.Type :help for more information.
scala>

You can confirm that it is working by typing the scala code:

您可以通过输入scala代码来确认它正在运行:

val s = "hello world"

Congratulations! You’re all set up!

恭喜你! 你们都准备好了!

Common Issue: Setting PATH in bash.

常见问题:在bash中设置PATH。

Homebrew should have taken care of all of this, but in case you need to add spark to your PATH, you’ll want to use:

Homebrew应该已经解决了所有这些问题,但是如果您需要在PATH中添加spark,则需要使用:

export SPARK_HOME=/usr/local/Cellar/apache-spark/2.0.1/libexecexport PYTHONPATH=/usr/local/Cellar/apache-spark/2.0.1/libexec/python/:$PYTHONP$

Just type that straight into your terminal.

只需将其直接输入您的终端即可。

I’m Jose Portilla, and I teach over 200,000 students about programming, data science, and machine learning on Udemy. You can check out all my courses here.

我是Jose Portilla,我在Udemy上为200,000多名学生提供有关编程,数据科学和机器学习的知识。 您可以在这里查看我所有的课程。

If you’re interested in learning Python for Data Science and Machine learning, check out my course here. (I also teach Full Stack Web Development with Django!)

如果您对学习Python进行数据科学和机器学习感兴趣, 请在此处查看我的课程 。 (我也教Django的Full Stack Web开发! )

翻译自: https://www.freecodecamp.org/news/installing-scala-and-apache-spark-on-mac-os-837ae57d283f/

macos 安装scala

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值