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

JVM target in Jupyter #328

Closed
2x2xplz opened this issue Feb 10, 2024 · 11 comments
Closed

JVM target in Jupyter #328

2x2xplz opened this issue Feb 10, 2024 · 11 comments

Comments

@2x2xplz
Copy link

2x2xplz commented Feb 10, 2024

Using version 0.11.0.385 of the Kotlin Jupyter kernel in a traditional (web-based) Jupyter notebook (not IDEA Kotlin notebook).

added kandy with %use kandy(0.5.0) and now when I try to plot I get the error:

Cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option

This is in the browser, not a Gradle project, how would I add this command-line flag, or is there another way to make the projects work together?

note: I downgraded to kandy 0.4.2 which does not specify JVM 11 in its build.gradle.kts and eliminated this error -- but a number of plot types are missing of course

2nd note: I created and used a custom kernel with JVM 21: python -m kotlin_kernel add-kernel --name "JDK21" --jdk ./path/to/jdk21 and still got the same error message`

@AndreiKingsley
Copy link
Collaborator

Hello! Could you please update version to the latest dev?

@AndreiKingsley
Copy link
Collaborator

Many kandy features may not work with an older version of kernel. However, you specify your JVM version:
Kotlin/kotlin-jupyter#81

@ileasile
Copy link
Contributor

Hi! What is the output of System.getProperty("java.version") when you use this newly created kernel?

@ileasile
Copy link
Contributor

Also, please update to the latest kernel version, namely 0.12.0.128, I've just published it to conda and pypi

@2x2xplz
Copy link
Author

2x2xplz commented Feb 10, 2024

Hi, thank you for the quick responses.

I upgraded to kernel 0.12.0.128 but still getting the same error.

System.getProperty("java.version") returns 21.0.2

I have incorporated JavaRuntimeUtils.assertVersionAtLeast(11) into my notebook, no effect

my Python version is 3.10.9

the contents of the run_kotlin_kernel\jars folder (from python -m kotlin_kernel detect-jars-location) is (maybe I am missing a necessary JARfile??):
image

@ileasile
Copy link
Contributor

Ok, could you please share the beginning of your kernel log? It should look like this
image

Also, please execute :classpath inside your notebook and share the output

@2x2xplz
Copy link
Author

2x2xplz commented Feb 11, 2024

OK it appears I was able to solve this issue by taking a hint from this comment from 2020 and adding the following line to run_kernel.py:

jar_args.append('-jvmTarget=11')

as the second-to-last line in the function, right above the subprocess.call() statement.

Ultimately this feels like this should be addressed by the kernel developers, not kandy, however using the kandy package (or lets-plot) raises the error, so perhaps some documentation for potential users would be helpful. I think this only affects Python-based Jupyter (not Kotlin notebooks) but it is tricky because you don't have a normal command line on which to add arguments, and no Gradle to set the configuration options.

Appreciate the help!

@ileasile
Copy link
Contributor

With the newer versions of kernel it shouldn't be needed, so probably several versions of kernel including older ones are installed on your computer.

I'm glad that the problem is resolved

@2x2xplz
Copy link
Author

2x2xplz commented Feb 11, 2024

With the newer versions of kernel it shouldn't be needed, so probably several versions of kernel including older ones are installed on your computer.

Hope that is the case- however I installed the newest Python (3.12.2), created a brand new virtual environment, installed only 2 packages (via pip) jupyter and kotlin-jupyter-kernel (0.12.0.128), have JVM 21 in my PATH, and still had the same exact error.

I'm glad that the problem is resolved

Me too! Spent way too many hours on setup. Happy it's working now.

@devcrocod
Copy link
Collaborator

@AndreiKingsley Can I close this issue or we have some related issues?

@AndreiKingsley
Copy link
Collaborator

No, I suppose we can close it, no recent related issues.

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

No branches or pull requests

4 participants