Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running the kotlin-jupyter kernel in google colab #357

Open
torgeir opened this issue Feb 23, 2022 · 5 comments
Open

Running the kotlin-jupyter kernel in google colab #357

torgeir opened this issue Feb 23, 2022 · 5 comments
Labels

Comments

@torgeir
Copy link

torgeir commented Feb 23, 2022

This might be more of a question than an issue - I'll have a go anyways;

Did anyone have success running the kotlin-jupyter kernel in google colab?

I tried running this notebook:

  • Edited the notebook source in the gist to change its kernelspec to "kotlin"
  • Opened the notebook from the gist
  • Watched the notebook fail loading the kernel for kotlin which is not installed yet
  • Ran the first cell to install it
  • Reloaded the notebook to make it connect again, as the kernel is now installed in the instance

Expected outcome:
The notebook connects to the new kernel as specified in the kernelspec json in the notebook source, and the following cell with kotlin code can be run.

Actual outcome:
The notebook repeatedly tries to connect, fails and crashes.

I previously had success with running clojure in colab in a similar fasion.

Any ideas? Thanks in advance.

@ileasile
Copy link
Contributor

Hi! To run Kotlin kernel, Java 11 should be installed on the machine, maybe that's the reason?

@torgeir
Copy link
Author

torgeir commented Feb 24, 2022

Attempted an install using the pip install-jdk package, still no juice

Edit: sudo apt install openjdk-11-jdk instead of install-jdk renders the same result

@torgeir
Copy link
Author

torgeir commented Feb 24, 2022

The logs are a bit hard to get to as the log window keeps closing every time the runtime attempts a reconnect, but in a flash I saw this.

/usr/bin/python2: No module named run_kotlin_kernel

Any ideas?

@cjwomack
Copy link

cjwomack commented Feb 4, 2023

Alternatively, you can download kotlin in colab... which is obviously slower (Please note I am a newbie to Kotlin and was going through a Android Kotlin tutorial with exercises when I thought about using a jupyter notebook and colab so I cannot guarantee the soundness of these approaches as alternatives)

Here are three ways:

  1. Using %%writefile and function call to compile and run
    compile_and_run_kotlin_function.ipynb

  2. Using custom cell magic which has nasty syntax highlighting thinking that is python
    cell_magic_with_annoying_python_syntax_errors_for_kotlin.ipynb

  3. Using a C program (which was hobbled quickly together from two examples so isn't probably the best C program around) to read text from a cell with %%script cell magic, which then compiles and runs the code. This means there are no annoying syntax highlighting with errors though. Obviously, you can compile the C program, put it on github and then wget or curl the program and hence get more screen space back by getting rid of 2 cells
    cell_magic_compile_run_kotlin.ipynb
    Download binary so 2 cells not used.
    cell_magic_compile_run_kotlin_download_bin.ipynb

@maxandersen
Copy link

I almost got kotlin kernel working in jupyter kernel.

the main reason it don't "just work" is because zmq in java don't support icp protocol which google colab uses.

you can workaround that by using icp proxy like https://gist.github.com/SpencerPark/e2732061ad19c1afa4a33a58cb8f18a9
but even when you have that done(*) then you hit the next snag that colab is jupyter 5.x based and here there is a user_variable in the json payload that kotlin kernel chokes on. I've opened #440 in hope of getting that fixed.

(*) I have a jbang script that setup various jvm kernels. one can run in colab using the following python snippet:

!pip install jbang
import jbang
jbang.exec("trust add https://github.com/jupyter-java")
jbang.exec("install-kernel@jupyter-java kotlin")

after that you can switch to the kernel with "kotlin ipc" in the name.

it works but stalls/fails due to the kernel failing on #440

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants