almond-sh / almond

A Scala kernel for Jupyter
https://almond.sh
BSD 3-Clause "New" or "Revised" License
1.59k stars 238 forks source link

How to install on Windows 10 #108

Open dchen23 opened 8 years ago

dchen23 commented 8 years ago

The launch file is a bash script, so how to install in cmd?

mslinn commented 7 years ago

I was able to run the launch file using Windows 10 Subsystem for Linux, however the jupyter-scala kernel is not listed afterwards:

(C:\Program Files\Anaconda3) C:\Users\mslin_000>jupyter kernelspec list
Available kernels:
  python3    C:\Program Files\Anaconda3\lib\site-packages\ipykernel\resources
rgbkrk commented 7 years ago

If I had to guess - jupyter is finding the kernel in the standard windows paths for Jupyter and the linux subsystem is installing in the expected place for a linux install.

From a python terminal (or IPython or the Jupyter notebook) run:

from jupyter_core.paths import jupyter_path
jupyter_path('kernels')

Try that both while using the Linux subsystem and while in a standard Windows prompt with Python.

mslinn commented 7 years ago

WSL bash:

$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from jupyter_core.paths import jupyter_path

jupTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
ytImportError: No module named jupyter_core.paths
>>>
e>>> jupyter_path('kernels')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>

NameError: name 'jupyter_path' is not defined

From Anaconda Prompt:

(C:\Program Files\Anaconda3) C:\Users\mslin_000>ipython
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from jupyter_core.paths import jupyter_path
   ...: jupyter_path('kernels')
   ...:
Out[1]:
['C:\\Users\\mslin_000\\AppData\\Roaming\\jupyter\\kernels',
 'C:\\Program Files\\Anaconda3\\share\\jupyter\\kernels',
 'C:\\ProgramData\\jupyter\\kernels']

In [2]: Some(1).map(_+2)

NameError: name 'Some' is not defined

Windows cmd:

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\Users\mslin_000>python
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from jupyter_core.paths import jupyter_path
>>> jupyter_path('kernels')
['C:\\Users\\mslin_000\\AppData\\Roaming\\jupyter\\kernels', 'C:\\Program Files\\Anaconda3\\share\\jupyter\\kernels', 'C:\\ProgramData\\jupyter\\kernels']
>>> Some(1).map(_+2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'Some' is not defined
rgbkrk commented 7 years ago

This makes definite sense then. The default python in the WSL is specifically for that Linux and doesn't use your Anaconda python. Some quick tips that I think should help with diagnosis:

Inside the WSL based Linux:

python -m pip install jupyter_core

Then open up the python terminal to run the commands I outlined before. I mostly want to compare paths. When I get back to my Windows machine I can investigate this and see if we can make this a cleaner process.

On a separate note, you definitely won't have Some available - this is the Python prompt, no Scala (or really many functional programming building blocks :wink:)

However, once we have your kernel for Scala detected properly you will likely be able to run jupyter console --kernel scala to get a Scala REPL reliant on jupyter-scala. :smile:

mslinn commented 7 years ago

WSL installs Jupyter-Scala in %LocalAppData%\lxss\home\mslinn\.local\share\jupyter\kernels\scala, which for me is C:\Users\mslin_000\AppData\Local\lxss\home\mslinn\.local\share\jupyter\kernels\scala.

From a WSL prompt:

$ ./jupyter-scala -h
JupyterScalaApp
Usage: jupyter-scala-app [options]
  --usage
        Print usage and exit
  --help | -h
        Print help message and exit
  --id  <value>
  --name  <value>
  --connection-file  <value>
  --erase-connection-file
  --quiet
  --exit-on-key-press
  --force
  --no-copy
  --jupyter-path  <value>
  --global

From a Windows Cmd prompt;

(C:\Program Files\Anaconda3) C:\Users\mslin_000>jupyter kernelspec list
Available kernels:
  python3    C:\Program Files\Anaconda3\lib\site-packages\ipykernel\resources

Perhaps an incantation something the following might work?

./jupyter-scala --jupyter-path /mnt/c/Program\ Files/Anaconda3/Lib/site-packages/notSureWhatGoesHere
mslinn commented 7 years ago

@rgbkrk Normally Python installs pip, but Windows for Linux requires you do that

$ sudo apt-get install python-pip

Now I installed, with sudo -H:

$ sudo -H python -m pip install jupyter_core

This test passed:

$ jupyter --version
4.2.1

No Jupyter console!?

$ jupyter console --kernel scala
jupyter: 'console' is not a Jupyter command

$ jupyter -h
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
               [--paths] [--json]
               [subcommand]

Jupyter: Interactive Computing

positional arguments:
  subcommand     the subcommand to launch

optional arguments:
  -h, --help     show this help message and exit
  --version      show the jupyter command's version and exit
  --config-dir   show Jupyter config dir
  --data-dir     show Jupyter data dir
  --runtime-dir  show Jupyter runtime dir
  --paths        show all Jupyter paths. Add --json for machine-readable
                 format.
  --json         output paths as machine-readable json

Available subcommands: migrate scala troubleshoot
rgbkrk commented 7 years ago

I might have given you too strict of an install there. jupyter_console is a separate package you can also pip install.

mslinn commented 7 years ago

WSL needs the gcc compiler and the Python development package:

$ sudo apt-get install build-essential python-dev

Now I tried to install Jupyter the same as for Ubuntu:

$ sudo -H pip install -I jupyter

I got several errors like this, and the installation failed.

Compiling /tmp/pip_build_root/pexpect/pexpect/async.py ...
  File "/tmp/pip_build_root/pexpect/pexpect/async.py", line 16
    transport, pw = yield from asyncio.get_event_loop()\
                             ^
SyntaxError: invalid syntax

I installed 0MQ dev package and retried installing Jupyter:

$ sudo apt-get install libzmq3-dev
$ sudo -H pip install -I jupyter
... snip ...
Successfully installed jupyter nbconvert ipykernel jupyter-console qtconsole notebook ipywidgets
traitlets nbformat jinja2 jupyter-core entrypoints pygments mistune ipython tornado jupyter-client
prompt-toolkit terminado ipython-genutils widgetsnbextension enum34 six decorator jsonschema
MarkupSafe configparser backports.shutil-get-terminal-size setuptools pickleshare simplegeneric
pexpect pathlib2 backports.ssl-match-hostname singledispatch certifi backports-abc pyzmq wcwidth
ptyprocess functools32

Now lets see how this works...

mslinn commented 7 years ago

OK, I can now run a Jupyter console from Windows Subsystem for Linux.

$ jupyter console --kernel scala
Jupyter console 5.0.0

jupyter-scala 0.4.0-RC1
ammonium 0.8.0
Scala 2.11.8
Java 1.8.0_111

In [1]: Some(1).map(_+2)
Out[1]: res0: Option[Int] = Some(3)

However, when I run:

$ jupyter notebook

Lynx starts up and displays the web page. I need a Windows browser instead. Since there is no way to launch Firefox from WSL, I just copy the URL from the bash console to native Windows web browser and the notebooks works perfectly for Scala:

$ jupyter notebook --no-browser
[I 16:52:20.884 NotebookApp] Serving notebooks from local directory: /home/mslinn
[I 16:52:20.884 NotebookApp] 0 active kernels
[I 16:52:20.885 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=0954635c4075f23bcb0da7f12b05310130dc7f668ed6ff07
[I 16:52:20.886 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
mslinn commented 7 years ago

I pasted in the Spark code into the notebook and got:

Creating SparkContext
java.net.SocketException: Cannot assign requested address (IOCTL SIOCGIFNETMASK failed)
  java.net.NetworkInterface.getAll(Native Method)
  java.net.NetworkInterface.getNetworkInterfaces(NetworkInterface.java:343)
  org.apache.spark.util.Utils$.findLocalInetAddress(Utils.scala:876)
  org.apache.spark.util.Utils$.org$apache$spark$util$Utils$$localIpAddress$lzycompute(Utils.scala:862)
  org.apache.spark.util.Utils$.org$apache$spark$util$Utils$$localIpAddress(Utils.scala:862)
  org.apache.spark.util.Utils$$anonfun$localHostName$1.apply(Utils.scala:919)
  org.apache.spark.util.Utils$$anonfun$localHostName$1.apply(Utils.scala:919)
  scala.Option.getOrElse(Option.scala:121)
  org.apache.spark.util.Utils$.localHostName(Utils.scala:919)
  org.apache.spark.SparkContext.<init>(SparkContext.scala:385)
  jupyter.spark.Spark$$anon$1.<init>(Spark.scala:186)
  jupyter.spark.Spark.sc$lzycompute(Spark.scala:186)
  jupyter.spark.Spark.sc(Spark.scala:181)
  jupyter.spark.package$.sc$lzycompute(package.scala:9)
  jupyter.spark.package$.sc(package.scala:9)
  $sess.cmd7Wrapper$Helper.<init>(cmd7.sc:24)
  $sess.cmd7Wrapper.<init>(cmd7.sc:149)
  $sess.cmd7$.<init>(cmd7.sc:79)
  $sess.cmd7$.<clinit>(cmd7.sc:-1)
sblack4 commented 7 years ago

Got it!

image

Download the link in this issue https://github.com/jupyter-scala/jupyter-scala/issues/1#issuecomment-315643483 and follow the directions in the Readme.txt.

Basically someone uploaded an already compiled kernel that you just need to plot into your kernels folder 😄