Kodi Community Forum

Full Version: kodi65 not python3 compatible?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In my first attempt to run my plugin using python 3 I am getting an error due to kodi65's import of kodiaddon

                                                from kodi65 import addon
                                              File "/home/fbacher/.kodi/addons/script.module.kodi65/lib/kodi65/__init__.py", line 6, in <module>
                                                from kodiaddon import Addon
                                            ModuleNotFoundError: No module named 'kodiaddon'

I know that I can eliminate my dependency on kodi65, but should this work?
(2019-11-12, 16:41)fbacher Wrote: [ -> ]In my first attempt to run my plugin using python 3 I am getting an error due to kodi65's import of kodiaddon

                                                from kodi65 import addon
                                              File "/home/fbacher/.kodi/addons/script.module.kodi65/lib/kodi65/__init__.py", line 6, in <module>
                                                from kodiaddon import Addon
                                            ModuleNotFoundError: No module named 'kodiaddon'

Appears to be caused by script.module.kodi65/lib/kodi65/_init_.py not using relative paths to imports:

from kodiaddon import Addon addon = Addon()
from listitem import ListItem, VideoItem, AudioItem
from itemlist import ItemList
from actionhandler import ActionHandler
from busyhandler import busyhandler as busy
from kodilogging import KodiLogHandler, config
from dialogbaselist import DialogBaseList
from localdb import LocalDB
from player import VideoPlayer

Should be:

from .kodiaddon import Addon addon = Addon()
from .listitem import ListItem, VideoItem, AudioItem
from .itemlist import ItemList
from .actionhandler import ActionHandler
from .busyhandler import busyhandler as busy
from .kodilogging import KodiLogHandler, config
from .dialogbaselist import DialogBaseList
from .localdb import LocalDB
from .player import VideoPlayer
However, once this is fixed there are .decode errors in kodiaddon, due to str.decode does not exist:

self.ID = self.addon.getAddonInfo('id').decode("utf-8")

My assumption is that no decoding is needed (but this needs verification).
Try the the upstream version from the kodi65 github repo which received Python3 fixes in March 2018:

https://github.com/phil65/script.module.kodi65

Your version is out of date.
(2019-11-12, 17:36)fbacher Wrote: [ -> ]My assumption is that no decoding is needed (but this needs verification).

You can't decode strings in python3 as they are already unicode, not byte strings as they were in python 2.

python:
Python 3.6.8 (default, Oct  7 2019, 12:59:55)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> mystring = "Hello World!!"
>>> print(type(mystring))
<class 'str'>
>>> mystring2 = b"Hello World!!"
>>> print(type(mystring2))
<class 'bytes'>
>>> print(mystring2.decode('utf-8'))
Hello World!!
>>> print(mystring.decode('utf-8'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'decode'
>>>

I think maybe if you use kodi-six and import xbmc from it you can avoid re-writing all the string code.

scott s.
.
It seems that kody65 utils.log from https://github.com/phil65/script.module....5/utils.py has an issue:

            File "/home/fbacher/.kodi/addons/script.module.kodi65/lib/kodi65/utils.py", line 55, in log
                                                arg = arg.decode("utf-8", 'ignore')
                                            AttributeError: 'str' object has no attribute 'decode'


Is there perhaps a newer version that I should be using?