-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Jupyter Notebook kernel dies: Problems with py5 in M3 MacOs 14.4.1 #456
Comments
Some extra info, import py5 from ipyhon (without using a jupyter notebook) works
No crashes so far. |
Hello, @ivanlen , thank you for opening this issue. I'm guessing this is going to be a challenging issue to address. The M3 computers are new and perhaps there is some new MacOS curveball to deal with. Since you are on 14.4.1, you don't have this problem. Here are a few things I will ask you to try that will help gather information.
|
Thanks for the questions, let me reply inline.
Just tried it, still crashes. I receive the meesage
I get an infinite spam of the error
Yes, this works! I have tried this with ipython and it was working fine, also by running
In jupyter
In ipython or python (that both are working)
Now running
However things are not working. I get the endless spam of Assertion failure errors
I am going to try to reinstall all the venv again to see if I have any luck (I am not very confident). So to wrap up. both in ipyhon and with python py5 is working, however it is not working with jupyter gui or jupyter console. This happens with both, version 17 and 21 of java. |
Ok, there's a bit of a pattern emerging here. Here are some more things to try:
$ jupyter --version
Selected Jupyter core packages...
IPython : 8.12.2
ipykernel : 6.26.0
ipywidgets : 8.1.1
jupyter_client : 8.6.0
jupyter_core : 5.5.0
jupyter_server : 2.10.1
jupyterlab : 4.0.9
nbclient : 0.7.4
nbconvert : 7.11.0
nbformat : 5.9.2
notebook : 7.0.4
qtconsole : 5.5.1
traitlets : 5.13.0
|
Some more things to try in Jupyter notebooks: import jpype
jpype.startJVM()
print(jpype.isJVMStarted()) If this fails, then this is a problem that is separate from py5. You might be experiencing the same thing discussed in this thread. If this works, then we'll have to see if the Jars py5 adds to the classpath before calling Also, you didn't say which version of Python you are using? I don't think it matters but it might inform my thinking here. |
This is the output for me
If all the other things don't work I can try to reinstall the whole venv and also downgrading some packages (but I am going to try your other suggested points before).
I am going to do this in a while. I am using jupyter for another thing and I don't want to break everything now (just in case)
Yes, crashing as well...
What do you mean here the version number, can you show me your |
This is working,
Yess, you are right, sorry about this, I am using Python 3.9.18 Thanks for all the ideas. I hope we can fix it :) |
Here is what I get. The >>> py5_tools.get_jvm_debug_info()
{'JAVA_HOME environment variable': '/usr/lib/jvm/java-17-openjdk',
'jvm version': (17, 0, 9),
'default jvm path': '/usr/lib/jvm/java-17-openjdk-17.0.9.0.9-3.fc39.x86_64/lib/server/libjvm.so'} |
Yes, I hope we can! You can get the list of Jars added to the classpath with this: jars = py5_tools.get_classpath().split(':') Get the output of that from IPython or someplace where py5 works. Then add that same list to the classpath with this: import jpype
for jar in jars:
jpype.addClassPath(jar)
jpype.startJVM()
print(jpype.isJVMStarted()) If this fails, see if you can isolate which Jar is tripping it up. |
Well, I have some news, I just created a new env. Reinstalled everything from scratch with Java17 activated (instead of 21) at the moment of the installation. Now I am getting this from iPython
So on this front we are moving forward, however I am still getting the error. I am going to do what you have proposed in your other message. |
I think we have something here (or the absence of something XD ) In [4]: import py5_tools
In [5]: py5_tools.get_jvm_debug_info()
Out[5]:
{'JAVA_HOME environment variable': '/opt/homebrew/Cellar/openjdk@17/17.0.10/libexec/openjdk.jdk/Contents/Home',
'jvm version': (17, 0, 10),
'default jvm path': '/opt/homebrew/Cellar/openjdk@17/17.0.10/libexec/openjdk.jdk/Contents/Home/lib/libjli.dylib'}
In [6]: jars = py5_tools.get_classpath().split(':')
In [7]: jars
Out[7]: [''] |
No, the classpath doesn't get set until the JVM starts, and since it crashes for you in Jupyter, you can't get the classpath by using Jupyter. Sorry if that wasn't clear. The first step is this, and run it in an environment where it works (IPython or generic Python interpreter) import py5_tools
import py5
jars = py5_tools.get_classpath().split(':') Once you have the list of Jars that are supposed to be on the classpath, try adding them to JPype without importing py5 in Jupyter, where you are getting the crash: import jpype
for jar in jars:
jpype.addClassPath(jar)
jpype.startJVM()
print(jpype.isJVMStarted()) |
Also, can you try creating a new environment and not using homebrew for Java? You can install Java with install-jdk, as outlined on py5's install py5 page. And finally, it might be worth trying the install with Anaconda. Anaconda does more than manage Python libraries, it can also manage the environment, including dll files for Windows, so files for Linux, and dylib files, as is the case for MacOS. |
Ok. I just tried this, and it is working: jars = [
'/Users/***/miniconda3/envs/py5coding/lib/python3.11/site-packages/py5/jars/py5.jar',
'/Users/***/miniconda3/envs/py5coding/lib/python3.11/site-packages/py5/jars/jogl-all.jar',
'/Users/***/miniconda3/envs/py5coding/lib/python3.11/site-packages/py5/jars/gluegen-rt.jar',
'/Users/***/miniconda3/envs/py5coding/lib/python3.11/site-packages/py5/jars/core.jar',
'/Users/***/miniconda3/envs/py5coding/lib/python3.11/site-packages/py5/jars/svg/batik.jar',
'/Users/***/miniconda3/envs/py5coding/lib/python3.11/site-packages/py5/jars/svg/svg.jar',
'/Users/***/miniconda3/envs/py5coding/lib/python3.11/site-packages/py5/jars/pdf/itext.jar',
'/Users/***/miniconda3/envs/py5coding/lib/python3.11/site-packages/py5/jars/pdf/pdf.jar',
'/Users/***/miniconda3/envs/py5coding/lib/python3.11/site-packages/py5/jars/dxf/dxf.jar',
]
import jpype
for jar in jars:
jpype.addClassPath(jar)
jpype.startJVM()
print(jpype.isJVMStarted())
|
Now I am with this one:
is working. Now lets see the notebook 🤞 ... NOPE:
🥀 Happy to help with any other info. |
Also, doing some research I found
So it might be something not releated to py5 but more general. This is bad news because you were super responsive and in these other projects devs don't see to be that responsive. |
Interesting, thank you for doing this research. @villares , this is an important clue for investigating future MacOS problems: if py5 crashes Jupyter, we should ask them to test the The root problem is that on MacOS the operating system requires the GUI to run on the process's main thread. Jupyter also needs the main thread for it to run itself. The When py5 runs in Jupyter it depends on
Right, this is not a py5 problem, but I did think of an idea. This will take more effort, but it will work. Consider installing Docker and running Jupyter Notebook through that. There already are Docker containers for Jupyter; this is how mybinder works. You'll need to install some py5 specific things in the Docker container to get it to work. You can pick out the relevant information in the binder directory of the py5examples repo (https://github.com/py5coding/py5examples/tree/main/binder). This will install a "virtual frame buffer" which is basically a fake display. This will work but it will run everything on the CPU and will not take advantage of the integrated graphics or GPU capabilities of your M3 machine. It might be possible to give Docker access to those resources outside of the container. I know you can do this on Linux but haven't done it myself. If you like this approach and you get the virtual frame buffer working and you think it is slow, you might want to investigate those options. In the mean time, give Docker a try and see if it meets your needs. |
Apparently this is a iPython kernel problem. There is a proposed solution to address the problem. Let see what happens when this is merged. |
Excellent, thank you @ivanlen. I will keep an eye on this PR. When it gets released, it will make things easier for py5 users with the Apple Silicon computers. |
merged. |
Yes, seems to be working 🥳 🎉 |
Hi, there, I just follow all the steps and check similar github issues but I wasn't able to fix my problem.
I am trying to use py5 in a jupyter notebook.
My top cell runs
Then I just
import py5
and the kernel dies:Running py5_tools I get
Also since I am using Java 21 I installed
Happy to provide any other info.
Maybe related to #452 #316
The text was updated successfully, but these errors were encountered: