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

ImageFilter imports numpy, causes issues on Arch Linux #59

Open
dkoch84 opened this issue Jul 28, 2021 · 3 comments
Open

ImageFilter imports numpy, causes issues on Arch Linux #59

dkoch84 opened this issue Jul 28, 2021 · 3 comments

Comments

@dkoch84
Copy link

dkoch84 commented Jul 28, 2021

Hello, see the following log:

2021-07-28 17:05:28.893 T:140612710434368   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.RuntimeError'>
                                            Error Contents: implement_array_function method already has a docstring
                                            Traceback (most recent call last):
                                              File "/home/daniel/.kodi/addons/script.embuary.helper/plugin.py", line 16, in <module>
                                                from resources.lib.plugin_content import *
                                              File "/home/daniel/.kodi/addons/script.embuary.helper/resources/lib/plugin_content.py", line 11, in <module>
                                                from resources.lib.image import *
                                              File "/home/daniel/.kodi/addons/script.embuary.helper/resources/lib/image.py", line 12, in <module>
                                                from PIL import ImageFilter,Image,ImageOps
                                              File "/usr/lib/python2.7/site-packages/PIL/ImageFilter.py", line 23, in <module>
                                                import numpy
                                              File "/usr/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
                                                from . import core
                                              File "/usr/lib/python2.7/site-packages/numpy/core/__init__.py", line 40, in <module>
                                                from . import multiarray
                                              File "/usr/lib/python2.7/site-packages/numpy/core/multiarray.py", line 13, in <module>
                                                from . import overrides
                                              File "/usr/lib/python2.7/site-packages/numpy/core/overrides.py", line 46, in <module>
                                                """)
                                            RuntimeError: implement_array_function method already has a docstring
                                            -->End of Python script error report<--

This reply from a numpy maintainer could very well be important: numpy/numpy#18848

"I'm sorry you are getting bounced around from repo to repo, but there's no bug in numpy that we re-introduced recently. numpy has never supported being run in Python sub-interpreters. Probably what changed is something in one of the Kodi plugins, like TMDbHelper, causing an import of numpy (probably through Pillow). If Kodi has moved to using sub-interpreters, all of the plugins will have to studiously avoid importing numpy entirely."

For my own purposes, I worked around the issue by simply removing the refrerence to ImageFilter, lines 12 and 76. I do not use this enough to know whether or not that breaks anything else, so I don't want to submit a PR, but I will if you think it appropriate. Essentially, l've lost the gaussian blur here.

                img = img.filter(ImageFilter.GaussianBlur(self.radius))

Thanks for the awesome addon(s) by the way, much appreciated.

Kindly,
Daniel

@dkoch84
Copy link
Author

dkoch84 commented Jul 28, 2021

I realize now that I'm using Leia, which is a version back, and thus not using the latest of your helper. Tell me to pound sand in that scenario. For what it's worth, I'm holding back for other compatibility reasons.

@torzdf
Copy link

torzdf commented Dec 3, 2021

This bug is reproducible in Ubuntu 21.04, Kodi 19.3 (19.3.0) Git:20211024-49a04cd6a7 Media Center Kodi

Crash log (snipped as nothing useful in the log, and cause of error is identified):

############## Kodi CRASH LOG ###############

################ SYSTEM INFO ################
 Date: Fri Dec  3 19:30:33 GMT 2021
 Kodi Options: 
 Arch: x86_64
 Kernel: Linux 5.15.5-051505-generic #202111250933 SMP Thu Nov 25 09:37:51 UTC 2021
 Release: Ubuntu 21.10 (Impish Indri)
############## END SYSTEM INFO ##############

############### STACK TRACE #################
=====>  Core file: /home/matt/core (2021-12-03 19:30:35.362973985 +0000)
        =========================================
[New LWP 17912]
[New LWP 17858]
[New LWP 17835]
[New LWP 17859]
[New LWP 17865]
[New LWP 17856]
[New LWP 17847]
[New LWP 17840]
[New LWP 17832]
[New LWP 17855]
[New LWP 17854]
[New LWP 17848]
[New LWP 17857]
[New LWP 17841]
[New LWP 17868]
[New LWP 17853]
[New LWP 17863]
[New LWP 17907]
[New LWP 17874]
[New LWP 17871]
[New LWP 17831]
[New LWP 17843]
[New LWP 17862]
[New LWP 17913]
[New LWP 17876]
[New LWP 17877]
[New LWP 17878]
[New LWP 17903]
[New LWP 17872]
[New LWP 17864]
[New LWP 17866]
[New LWP 17873]
[New LWP 17905]
[New LWP 17860]
[New LWP 17867]
[New LWP 17869]
[New LWP 17904]
[New LWP 17849]
[New LWP 17911]
[New LWP 17914]
[New LWP 17906]
[New LWP 17834]
[New LWP 17861]
[New LWP 17908]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/usr/lib/x86_64-linux-gnu/kodi/kodi.bin'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f26a3931498 in ?? () from /usr/lib/python3/dist-packages/numpy/core/_multiarray_umath.cpython-39-x86_64-linux-gnu.so
[Current thread is 1 (Thread 0x7f261a7fc640 (LWP 17912))]

Output from debug logging when forcing an error in numpy's __init__.py:

2021-12-03 19:18:35.203 T:16795   ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'RuntimeError'>
                                                   Traceback (most recent call last):
                                                     File "/home/matt/.kodi/addons/script.embuary.helper/service.py", line 6, in <module>
                                                       from resources.lib.service_monitor import *
                                                     File "/home/matt/.kodi/addons/script.embuary.helper/resources/lib/service_monitor.py", line 12, in <module>
                                                       from resources.lib.utils import split
                                                     File "/home/matt/.kodi/addons/script.embuary.helper/resources/lib/utils.py", line 20, in <module>
                                                       from resources.lib.image import *
                                                     File "/home/matt/.kodi/addons/script.embuary.helper/resources/lib/image.py", line 12, in <module>
                                                       from PIL import ImageFilter,Image,ImageOps,ImageEnhance
                                                     File "/usr/lib/python3/dist-packages/PIL/ImageFilter.py", line 20, in <module>
                                                       import numpy
                                                     File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 1, in <module>
                                                       raise RuntimeError()
                                                   RuntimeError
                                                   -->End of Python script error report<--
                                                   
2021-12-03 19:18:35.203 T:16795   DEBUG <general>: onExecutionDone(3, /home/matt/.kodi/addons/script.embuary.helper/service.py)
2021-12-03 19:18:35.211 T:16795    INFO <general>: Python interpreter stopped

As things stand, it looks like that any libs that pull in numpy basically break Kodi :/

I am happy to investigate workarounds (I do a fair amount in CV) but don't want to invest time if this would be of no use to you.

@torzdf
Copy link

torzdf commented Dec 4, 2021

I've just seen your wiki note re: this being a known issue. I have solved my issue (for now) by upgrading my system pillow to v8.4.0, but I'm fairly sure this kind of thing is likely to be a recurring theme with any plugins that depend on something that imports numpy, even if that issue does turn out to be upstream from the plugin.

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

2 participants