2019-04-14, 18:34
I've been trying to adjust my code to be both Python 2&3 friendly, based mainly on kodi.wiki but also Googling around as it doesn't work even if everybody says that it should.
I have structure:
In contextmenu.py I need to import common.py, so in Python 2 I had just:
Now, in order to adjust it also to Python 3, all sources say that this should be changed to:
Is there anything that I'm still missing?
I have structure:
Code:
service.subsmangler/
----resources/
--------__init__.py
--------lib/
------------__init__.py
------------common.py
------------contextmenu.py
In contextmenu.py I need to import common.py, so in Python 2 I had just:
python:import common
Now, in order to adjust it also to Python 3, all sources say that this should be changed to:
but after changing it, I get an error in Kodi log saying:python:from __future__ import absolute_import
from . import common
Code:
2019-04-14 18:15:58.775 T:140410114529024 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.ValueError'>
Error Contents: Attempted relative import in non-package
Traceback (most recent call last):
File "/home/kiziuk/.kodi/addons/service.subsmangler/resources/lib/contextmenu.py", line 9, in <module>
from . import common
ValueError: Attempted relative import in non-package
-->End of Python script error report<--
Is there anything that I'm still missing?