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
Kodi v19 crashes when PIL imports numpy #5320
Comments
I played with an issue a bit and found out that the underlying issue is the lack of sub-interpreter support in C++ numpy modules I am opening a NumPy bug now. |
Thanks for investigating further. |
@radarhere isn't it better to provide an option for Pillow users to disable internal numpy invocation somehow? For example, by a method or constructor option that is on by default. See attached issue: NumPy developers claim sub-interpreter support is still in near-beginning state. |
If I'm understanding correctly, Pillow's only contribution to this bug is the fact that it uses numpy? How do you feel about this idea - radarhere@420f4e9 - moving the numpy import from the start of ImageFilter into the Color3DLUT class, so that it is only imported when necessary? |
I like the idea. Basically @jurialmunkey did very similar fix lazy-loading Pillow.
|
I've created #5323. |
I just tried Flatpak's Kodi Matrix version and there's no Pillow issue there -probably because the packaged Python libraries there are earlier versions, or it's based on another Linux distro altogether. |
The new Pillow version was out yesterday while I was asleep. |
Hi. I don't know what you're talking about. The last Pillow release was 8.1.2, three weeks ago, and the fix that we've put together for this issue hasn't been accepted into master yet, let alone a release. |
Yes I was mistaken about the Pillow release. |
@basilgello I opened an issue on numpy about this at numpy/numpy#18848 (comment) which was closed with this quote: Not necessarily. Try, for example, temporarily inserting a raise RuntimeError() at the top of Since numpy has never worked with sub-interpreters, the (re)introduced bug is in the code that is trying to import numpy, so I'm going to close this." I'm not even close to try that, maybe you can help? |
Well, on Arch Linux I see the following location of packaged numpy targeting Python 3.9:
/usr/lib/python3.9/site-packages/numpy/__init__.py
If you confirm you have that file installed on a troubled machine, we can edit it and check kodi.log for traceback.
|
But I have no clue what to insert and on what line. |
I'm sorry to bother you again, but numpy peeps said it's definitely a pillow issue, Kodi devs marked the issue as externally solved, and the fact remains: |
@CgCgCgCgCg Please apply this patch to the file: diff --git a/usr/lib/python3.9/site-packages/numpy/__init__.py b/usr/lib/python3.9/site-packages/numpy/__init__.py
index 6021e6d..1739d5f 100644
--- a/usr/lib/python3.9/site-packages/numpy/__init__.py
+++ b/usr/lib/python3.9/site-packages/numpy/__init__.py
@@ -106,6 +106,9 @@ available as array methods, i.e. ``x = np.array([1,2,3]); x.sort()``.
Exceptions to this rule are documented.
"""
+
+raise RuntimeError()
+
import sys
import warnings
|
Could you point me to an exact comment where that was said? |
That's what I understood from this comment: |
Error starts in line 1794:
|
Now post the link to this excerpt to where numpy authors asked you to provide this info & restore original __inir__.py file.
|
I don't think they are pointing the problem back to Pillow. I appreciate that you feel like this issue is just being passed around (although to be fair, both jurialmunkey/plugin.video.themoviedb.helper@d029022 and our own #5323 have tried to work around the situation). You believe that themoviedb.helper is importing Pillow, which then imports numpy, and then somehow, numpy causes a crash in https://github.com/xbmc/xbmc, right? Except since #5323, Pillow only imports numpy from I can't reproduce this problem from the command line in a virtual machine right, and it only happens on Linux? |
If I read the error correctly Kodi's script.module.websocket is the culprit that imports numpy. |
I decided to edit directly line 37 of /home/k/.kodi/addons/script.module.websocket/lib/websocket/_abnf.py and replace "import numpy" with: After initial testing this seems to solves crashes on Arch Linux and Kodi 19.1 seems to work fine. |
This happens on Arch Linux with all addons and skins that use PIL image libraries.
Information on TheMovieDb Helper Kodi addon where its dev did a workaround here:
jurialmunkey/plugin.video.themoviedb.helper#445
A Kodi dev mentioned that this is a PIL / Numpy issue not a Kodi issue so I should ask here:
xbmc/xbmc#19324
Thank you for any possible solutions.
The text was updated successfully, but these errors were encountered: