Ravaal
Ravaal

Reputation: 3359

How do I install Scala in Jupyter IPython Notebook?

Here's a few links that I went to and did exactly what they said. I don't know what I'm doing wrong.

https://github.com/alexarchambault/jupyter-scala
https://github.com/ipython/ipython/wiki/IPython-kernels-for-other-languages
https://github.com/apache/incubator-toree
http://jcrudy.github.io/blog/html/2013/12/08/introduction_to_iscala.html

None of this is working. It may be some way that my node is configured. I just don't know. Please help.

Upvotes: 21

Views: 48192

Answers (8)

Marcin
Marcin

Reputation: 238309

spylon-kernel hasn't seen an update in years. These days its much better to use almond.

Upvotes: 0

Idhem
Idhem

Reputation: 964

For mac, I needed only to 3 commands to add Scala and run it with Spark (I had it already installed) on my Jupyter notebook

pip install spylon-kernel

python -m spylon_kernel install

ipython notebook

Once you run them on your terminal, you'll have spylon-kernel in your notebook, which can be used as your a Scala notebook.

Upvotes: 2

Kalyan Dhara
Kalyan Dhara

Reputation: 21

Make sure spark is installed in local along with SPARK_HOME is added or exported in .profile/environment file.

If not, you might get stuck with the following message:

"Intitializing Scala interpreter ..."

without any result.

Upvotes: 2

Mike
Mike

Reputation: 790

I've just run:

  • conda create --name base2 --clone base to create an env just like base.

  • conda activate base2 to move to the new env.

  • conda install -c conda-forge spylon-kernel.

  • python -m spylon_kernel install --user. create a kernel spec for Jupyter notebook

  • jupyter-notebook

...and works just fine.

I'm using:

  • Anaconda 4.7.12
  • Jupyter-notebook 6.0.1
  • Ubuntu 18.04
  • ipykernel 5.1.3
  • ipython 7.9.0
  • ipython_genutils 0.2.0
  • jupyter_client 5.3.4
  • jupyter_core 4.6.0
  • traitlets 4.3.3

from def suma(a: Int) = a + 3

enter image description here

Upvotes: 6

user5012823
user5012823

Reputation:

I can't add a comment to Heapify's answer, but his solution worked for JupyterLab on Windows without problems.

I cut and pasted his code into an Anaconda Powershell prompt

pip install spylon-kernel
python -m spylon_kernel install
jupyter notebook

And refreshed my anacopnda launcher and the spylon project option was available.

Upvotes: 3

Heapify
Heapify

Reputation: 2901

I tried the following with Jupyterhub notebook and it works seamlessly:

# Step 1: Install spylon kernel
pip install spylon-kernel

# Step 2: create a kernel spec
python -m spylon_kernel install

# Step 3: start jupyter notebook 
jupyter notebook

PS: to list all installed kernels, you can run the following command:

jupyter kernelspec list

Upvotes: 22

Saqib Shamsi
Saqib Shamsi

Reputation: 542

You can use the information given here.

Ensure you have IPython 3 installed. ipython --version should return a value >= 3.0. If it's not the case, a quick way of setting it up consists in installing the Anaconda Python distribution, and then running

$ pip install --upgrade "ipython[all]"

ipython --version should then return a value >= 3.0.

Download the Jupyter Scala binaries for Scala 2.10 (txz or zip) or Scala 2.11 (txz or zip), and unpack them in a safe place. Then run once the jupyter-scala program (or jupyter-scala.bat on Windows) it contains. That will set-up the Jupyter Scala kernel for the current user.

Check that Jupyter/IPython knows about Jupyter Scala by running

$ jupyter kernelspec list

This should print, among others, a line like

scala211

(or scala210 dependending on the Scala version you chose).

Then run either IPython console with

$ ipython console --kernel scala211

and start using the Jupyter Scala kernel straightaway, or run Jupyter Notebook with

$ jupyter notebook

and create Scala 2.11 notebooks by choosing Scala 2.11 in the dropdown in the upper right of the Jupyter Notebook start page.

Note: Since IPython has now been replaced by Jupyter, we replaced ipython in the above commands with jupyter.

Upvotes: 17

Ravaal
Ravaal

Reputation: 3359

The answer for Linux can be found here.

Install Scala. Add these lines to ~/.bashrc

export SCALA_HOME=/usr/local/share/scala export PATH=$PATH:$SCALA_HOME/bin:$PATH Follow these instructions from the GitHub site:

Download and unpack pre-packaged binaries Scala 2.11. Unpack each downloaded archive(s), and, from a console, go to the bin sub-directory of the directory it contains. Then run the following to set-up the corresponding Scala kernel:

./jove-scala --kernel-spec

Upvotes: 2

Related Questions