Kodi add-on and python dependency

Hello,

I use the Arctic: Zephyr - Reloaded skin on Kodi, previously on libreelec and now on NixOS. Unfortunately, I have a problem with the Embruary Helper dependency that this skin needs.

When I put kodi in debug mode, I can see this following lines:

[kodi@kodi-htpc:~]$ grep -A15 "PythonToCppException" .kodi/temp/kodi.log 
2022-09-23 17:38:51.776 T:1052    ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'ModuleNotFoundError'>
                                                   Error Contents: No module named 'PIL'
                                                   Traceback (most recent call last):
                                                     File "/home/kodi/.kodi/addons/script.embuary.helper/service.py", line 6, in <module>
                                                       from resources.lib.service_monitor import *
                                                     File "/home/kodi/.kodi/addons/script.embuary.helper/resources/lib/service_monitor.py", line 12, in <module>
                                                       from resources.lib.utils import split
                                                     File "/home/kodi/.kodi/addons/script.embuary.helper/resources/lib/utils.py", line 20, in <module>
                                                       from resources.lib.image import *
                                                     File "/home/kodi/.kodi/addons/script.embuary.helper/resources/lib/image.py", line 12, in <module>
                                                       from PIL import ImageFilter,Image,ImageOps,ImageEnhance
                                                   ModuleNotFoundError: No module named 'PIL'
                                                   -->End of Python script error report<--

But, PIL is installed by:

[kodi@kodi-htpc:~]$ grep -A5 -B4 "pillow" /etc/nixos/configuration.nix 
    (
      let 
        my-python-packages = python-packages: with python-packages; [
          pillowfight
        ];
        python-with-my-packages = python3.withPackages my-python-packages;
      in
        python-with-my-packages
    )

And see in modules:

[kodi@kodi-htpc:~]$ python
Python 3.9.13 (main, May 17 2022, 14:19:07) 
[GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> help('modules')

Please wait a moment while I gather a list of all available modules...

PIL [...]

Does anyone know how to correct the error?

Thank you for reading and helping.

It looks like the best way to do this is to make a derivation for the addon (see here for examples) and then override your Kodi install to add the package.

Unfortunately we cannot package many kodi skins. The prevailing norm for many of the fancy skins is to dynamically rewrite it’s own code at runtime and it is very incredible to a point of being “impossible” in a practical sense to do so.

This isn’t the python that kodi uses: kodi defines its own which includes pil(low) as seen here.

I’m curious why this isn’t working. I use that skin as well. How do I reproduce the error and visually what will I see to indicate a problem? With kodi I mentally ignore errors which don’t have noticable impact because I always watch kodi from a couch using a tv remote to control it.

I would like to look into your issue so please list as many details that could be relevant that you can.

Thanks!

@winter: The skin need a lot of add-on. Add each take a long time and I don’t think that would fix the problem

@aanderse: A notification appears at kodi startup and in several menus (movies, tv shows, etc). I don’t know how to reproduce because it’s a fresh install. If it helps, here is my configuration.nix.

And again, even if all dependencies were packaged it still would not run. Many kodi skins need to be able to write and rewrite their own resources and sometimes even code. There is no practical way to package this for nixpkgs.

I wasn’t able to reproduce your error. This error is strange because PIL should be available to kodi… Can you please try a fresh install of kodi and use version 1.1.61 of the skin? This is the version I am currently using.

Hello,

I just reinstall nixos and your recommantations in a VM to test. I have the same problem.
You can see my installation steps in this video (30Mo for 12 minutes).

Thanks for you time!

Thanks for the video. Very helpful to see exactly what is going on for you. I’ll try to find some time to fire up a vm and work through it.

Also… I didn’t realize our graphical installer was so awesome! Great work to those involved in that!

1 Like

Hello,

Just for information, this issue is still present in nixos 22.11.
Anyone known a workaround?

cc @aanderse, who works on Kodi things :slight_smile:

1 Like

I’m sorry this post really slipped by my attention.

I ended up going through your video a few times and had inconsistent results. With the time spent I wasn’t able to figure out what the issue was nor consistently reproduce it. There is a reason for your issue… I’m just not sure what. I’m trying to find the motivation to continue investigation.

There are a few things I want to mention:

  • Automatic add-on updates are enabled by default and this seems like a bad default if nix is managing software… though a good idea if nix is not. We should consider changing this value. I wonder if any add-ons are being automatically updated in your case, though doubt it.
  • I wonder if your issue still exists on the latest version of kodi, though I assume it still will.

The kodi team isn’t overly active on kodi. We keep it up to date and occasionally do some code cleanup. This puts you in a position of being under supported, which is not fair to you. I wish we were more active and helpful… but this isn’t the reality, likely because kodi mostly works for us and isn’t the easiest code base to work with.

If anyone else is interested in helping out we could always use a hand.

1 Like