Bachmann1234/java9_kernel

Having trouble - kernel dies

Closed this issue · 19 comments

i def have metakernel installed so not really sure what's going on.. Any ideas?

[I 12:51:41.616 NotebookApp] Serving notebooks from local directory: /Users/macbook/.ipython/kernels
[I 12:51:41.616 NotebookApp] 0 active kernels
[I 12:51:41.616 NotebookApp] The IPython Notebook is running at: http://localhost:8888/
[I 12:51:41.616 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 12:51:51.800 NotebookApp] Creating new notebook in
[I 12:51:52.529 NotebookApp] Kernel started: f4443aa2-d714-40c4-83c7-5c5378ab67a4
Traceback (most recent call last):
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 5, in
from metakernel import MetaKernel as Kernel
ImportError: No module named 'metakernel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 9, in
from ipykernel.kernelbase import Kernel
ImportError: No module named 'ipykernel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"main", mod_spec)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/macbook/.ipython/kernels/java9/javakernel/main.py", line 1, in
from kernel import JavaKernel
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 11, in
from IPython.kernel.zmq.kernelbase import Kernel
ImportError: No module named 'IPython'
[I 12:51:55.530 NotebookApp] KernelRestarter: restarting kernel (1/5)
Traceback (most recent call last):
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 5, in
from metakernel import MetaKernel as Kernel
ImportError: No module named 'metakernel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 9, in
from ipykernel.kernelbase import Kernel
ImportError: No module named 'ipykernel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"main", mod_spec)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/macbook/.ipython/kernels/java9/javakernel/main.py", line 1, in
from kernel import JavaKernel
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 11, in
from IPython.kernel.zmq.kernelbase import Kernel
ImportError: No module named 'IPython'
[I 12:51:58.540 NotebookApp] KernelRestarter: restarting kernel (2/5)
Traceback (most recent call last):
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 5, in
from metakernel import MetaKernel as Kernel
ImportError: No module named 'metakernel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 9, in
from ipykernel.kernelbase import Kernel
ImportError: No module named 'ipykernel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"main", mod_spec)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/macbook/.ipython/kernels/java9/javakernel/main.py", line 1, in
from kernel import JavaKernel
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 11, in
from IPython.kernel.zmq.kernelbase import Kernel
ImportError: No module named 'IPython'
[I 12:52:01.552 NotebookApp] KernelRestarter: restarting kernel (3/5)
Traceback (most recent call last):
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 5, in
from metakernel import MetaKernel as Kernel
ImportError: No module named 'metakernel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 9, in
from ipykernel.kernelbase import Kernel
ImportError: No module named 'ipykernel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"main", mod_spec)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/macbook/.ipython/kernels/java9/javakernel/main.py", line 1, in
from kernel import JavaKernel
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 11, in
from IPython.kernel.zmq.kernelbase import Kernel
ImportError: No module named 'IPython'
[W 12:52:03.106 NotebookApp] Timeout waiting for kernel_info reply from f4443aa2-d714-40c4-83c7-5c5378ab67a4
[I 12:52:04.564 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel f4443aa2-d714-40c4-83c7-5c5378ab67a4 restarted
Traceback (most recent call last):
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 5, in
from metakernel import MetaKernel as Kernel
ImportError: No module named 'metakernel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 9, in
from ipykernel.kernelbase import Kernel
ImportError: No module named 'ipykernel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"main", mod_spec)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/macbook/.ipython/kernels/java9/javakernel/main.py", line 1, in
from kernel import JavaKernel
File "/Users/macbook/.ipython/kernels/java9/javakernel/kernel.py", line 11, in
from IPython.kernel.zmq.kernelbase import Kernel
ImportError: No module named 'IPython'
[W 12:52:07.574 NotebookApp] KernelRestarter: restart failed
[W 12:52:07.574 NotebookApp] Kernel f4443aa2-d714-40c4-83c7-5c5378ab67a4 died, removing from map.
ERROR:root:kernel f4443aa2-d714-40c4-83c7-5c5378ab67a4 restarted failed!
[W 12:52:07.594 NotebookApp] Kernel deleted before session
[W 12:52:07.595 NotebookApp] 410 DELETE /api/sessions/a4f23412-a1a7-4789-8b52-727ec89d8d2e (::1) 1.24ms referer=http://localhost:8888/notebooks/Untitled.ipynb?kernel_name=java
^C[I 12:52:15.204 NotebookApp] interrupted
Serving notebooks from local directory: /Users/macbook/.ipython/kernels
0 active kernels
The IPython Notebook is running at: http://localhost:8888/
Shutdown this notebook server (y/[n])? y
[C 12:52:16.779 NotebookApp] Shutdown confirmed
[I 12:52:16.780 NotebookApp] Shutting down kernels

It looks like something off with the pythonpath
@dsblank do you have any thoughts on this. I get the feeling you have more ipython experience than me

Python path should be good

ls /usr/local/lib/python2.7/site-packages/

Babel-1.3-py2.7.egg-info/
IPython/
Jinja2-2.8.dist-info/
MarkupSafe-0.23-py2.7.egg-info/
PyGithub-1.25.2-py2.7.egg-info/
Pygments-2.0.2.dist-info/
Sphinx-1.3.1.dist-info/
pycache/
_cffi_backend.so
alabaster/
alabaster-0.7.4.dist-info/
appnope/
appnope-0.1.0.dist-info/
babel/
backports/
backports.ssl_match_hostname-3.4.0.2-py2.7.egg-info/
beautifulsoup4-4.4.1.dist-info/
bs4/
certifi/
certifi-2015.9.6.2.dist-info/
cffi/
cffi-1.3.0.dist-info/
dateutil/
decorator-4.0.4.dist-info/
decorator.py
decorator.pyc

etc….

On Nov 17, 2015, at 1:02 PM, Matt Bachmann notifications@github.com wrote:

It looks like something off with the pythonpath
@dsblank https://github.com/dsblank do you have any thoughts on this. I get the feeling you have more ipython experience than me


Reply to this email directly or view it on GitHub #11 (comment).

crap.. it's looking for python 3.4.3 Any ideas how to fix?

double crap.. does this require python 3? Anaconda work?

I can't look in detail right away but ill try to look tonight.

Update: installed Anaconda and it appears to be finding the modules, however, now I'm getting a KeyError: 'JAVA_9_HOME'

Ah! Ok that one is easy.

So in the readme I talk about environment variables that need to be defined

KULLA_HOME - The full path of kulla.jar
JAVA_9_HOME - like JAVA_HOME but pointing to a java 9 environment

Judging by the error it sounds like JAVA_9_HOME is not defined. You can check this by running

echo $JAVA_9_HOME

If nothing comes out then its not defined

Makes sense, however I thought I did assign the enviro variables in the kernel.json. Do I have to also define them in say, my bash profile? Output of echo $Java_9_HOME is empty so obviously something isn't working right.

01:30 PM macbook@macbook:$~ cat .ipython/kernels/java/kernel.json

{
"argv": ["python3", "/Users/macbook/.ipython/kernels/java9/javakernel",
"-f", "{connection_file}"],
"display_name": "Java 9",
"language": "java",
"env" : {
"Java_9_HOME": "/Library/Java/JavaVirtualMachines/jdk1.9.0.jdk",
"KULLA_HOME": "/Library/Java/JavaVirtualMachines/kulla.jar"
}
}

You have to spell it correctly, including upper case.

On Tue, Nov 17, 2015 at 1:34 PM, Michael Quatrani notifications@github.com
wrote:

Makes sense, however I thought I did assign the enviro variables in the
kernel.json. Do I have to also define them in say, my bash profile? Output
of echo $Java_9_HOME is empty so obviously something isn't working right.

01:30 PM macbook@macbook:$~ cat .ipython/kernels/java/kernel.json {
"argv": ["python3", "/Users/macbook/.ipython/kernels/java9/javakernel",
"-f", "{connection_file}"],
"display_name": "Java 9",
"language": "java",
"env" : {
"Java_9_HOME": "/Library/Java/JavaVirtualMachines/jdk1.9.0.jdk",
"KULLA_HOME": "/Library/Java/JavaVirtualMachines/kulla.jar"
}
}


Reply to this email directly or view it on GitHub
#11 (comment)
.

@Qtrain ah, I forgot you can define environment varioables in the kernel.json. So my test would not of worked anyway. I defined my variables in my environment but that way is fine.

But @dsblank is correct. They are case sensitive so you need to capitalize it

@dsblank Ooooooops. Thanks for that catch.

@Bachmann1234 Got it working. A couple of things:

I still don't get any values if I do echo $JAVA_9_HOME but that might be because I'm defining them in the kernel.json.

Might want to update the README to specify Python3

for the JAVA_9_HOME variable i had to set it to the full path to the image, which is the same as the regular java variable so instead of

/Library/Java/JavaVirtualMachines/jdk1.9.0.jdk
I used
/Library/Java/JavaVirtualMachines/jdk1.9.0.jdk/Contents/Home

also do to the location of the jdk on my mac I had to use
../../Library/Java/JavaVirtualMachines/jdk1.9.0.jdk/Contents/Home

path to the kulla jar remained the same, but, you might need to remind people that kulla needs to have executable permissions.

Thanks to both of you for your help and awesome project. I look forward to using this..

Thanks for the feedback. Ill think about it in detail and update the readme some time this week.

I had thought the kernel could work on 2 or 3. But ill dig into it. Clearly it did not work in this case.

@Bachmann1234 The kernel can work on Python2 or Python3. Right now, the user must edit the kernel.json to specify which Python (and maybe even where). An installer could be made. I can work with you for that, but as this is all based on alpha-quality Java stuff, that is probably premature. People should not expect this to work perfectly.

Having said that, I am planning on using it with one of my classes in the Spring.

Do you know how to report errors to the JShell project? For example, this gives an error:

System.out.println("hello " + "world");

I assume that is either a Java issue, or a JShell issue.

@dsblank Saw your comment and the code actually worked for me

image

I suspect your report the issue to the OpenJdk.

Seems like String concatination issue. I am seeing it as well, but I am using an older build. if it works for @Qtrain then it it seems like you should try updating Java 9. It is alpha after all. Changing a lot

-> String batman = "Bat" + "Man";

-> batman
|  Variable batman of type String has value null

@dsblank

http://geophile.com/jshell/

JShell is an open-source project and contributions are welcome. Contributions can take the form of bug-fixes, new commands, suggestions, new features in the JShell core, etc. I'll act as coordinator and release updates periodically. If you want to help out but don't know what to work on, contact me at jao@geophile.com. If you send me your email address, I'll keep you posted on JShell developments.

Here are some projects that need to be done:

Platform-specific documentation and help facilities (especially EPOC, but also Windows and Unix).
Commands:
mv: Put a general-purpose copy and delete implementation in jshell.OS (and called from jshell.command.mv). Allow OS-specific overrides, e.g. to spawn an mv command.
grep: based on glob patterns, not regular expressions.
chmod
tail
head
sed
awk
wc
A JShell scripting language: Be able to read JShell commands from a text file; Add simple control constructs.
An integrated editor.
An awt-based console to replace the standard Java console. This should permit more flexible keyboard handling and enable things such as emacs key bindings, command recall using arrow keys, and suspending foreground jobs.
Get rid of all the CommandElementExpander$Transition* and LexerAutomaton$Transition classes. They greatly increase JShell's footprint. The functionality of these classes could be coded in a much more memory-efficient way, with only a slight loss in program readability.
Support JShell on other platforms.
An XSLT style sheet to generate plain-text documentation.

https://code.google.com/p/jshell/source/browse/repo/org/jshell/?r=12

Woah, wait a minute there. This kernel is not for that project. Or at least im fairly sure its not.

This kernel is for http://openjdk.java.net/jeps/222 They just unfortunately share a name

@Qtrain Can you say what version/build you are using of Java9 and of JShell? Looks like I need to build one or the other or both.

@Bachmann1234 Note that it wasn't string concatenation in general, but in this specific use.

@Qtrain Thanks for the info! Some of those items aren't necessary when used in the Jupyter notebook or console. But they would be needed to integrate the output with further Java processing.

BTW, if you use java9_kernel with MetaKernel, then you get parallel Java for free. See:

https://athena.brynmawr.edu/jupyter/hub/dblank/public/Experiments/Java9.ipynb#Parallel-Magics

@Bachmann1234 oops again! Thanks for the correction.
@dsblank Yep np!

Java Version
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b91)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b91, mixed mode)

JShell
jar kulla.jar
| Welcome to the Java REPL -- Version 0.411
| Type /help for help

edit: @dsblank Thanks Doug! Looks great!

@dsblank weird. In my snippet I was finding concatenation leading to a null. Like in my snippet.