ModuleNotFoundError: No module named '_ctypes'
candrews opened this issue · 15 comments
The Yatse plugin no longer work with Kodi master (aka 19 aka Matrix).
I believe this problem is due to the recent upgrade in Kodi to Python 3: xbmc/xbmc#16116
Here's the logged information:
2019-10-16 10:35:03.122 T:195225 INFO: initializing python engine.
2019-10-16 10:35:03.122 T:195225 DEBUG: CPythonInvoker(13, /home/mythtv/.kodi/addons/script.yatse.kodi/default.py): start processing
2019-10-16 10:35:03.138 T:195225 DEBUG: -->Python Interpreter Initialized<--
2019-10-16 10:35:03.138 T:195225 DEBUG: CPythonInvoker(13, /home/mythtv/.kodi/addons/script.yatse.kodi/default.py): the source file to load is "/home/mythtv/.kodi/addons/script.yatse.kodi/default.py"
2019-10-16 10:35:03.138 T:195225 DEBUG: CPythonInvoker(13, /home/mythtv/.kodi/addons/script.yatse.kodi/default.py): setting the Python path to /home/mythtv/.kodi/addons/script.yatse.kodi:/home/mythtv/.kodi/addons/plugin.video.youtube/resources/lib/:/home/mythtv/.kodi/addons/script.module.certifi/lib:/home/mythtv/.kodi/addons/script.module.chardet/lib:/home/mythtv/.kodi/addons/script.module.idna/lib:/home/mythtv/.kodi/addons/script.module.inputstreamhelper/lib:/home/mythtv/.kodi/addons/script.module.kodi-six/libs:/home/mythtv/.kodi/addons/script.module.python.twitch/resources/lib:/home/mythtv/.kodi/addons/script.module.requests/lib:/home/mythtv/.kodi/addons/script.module.six/lib:/home/mythtv/.kodi/addons/script.module.urllib3/lib:/home/mythtv/.kodi/addons/script.module.urlresolver.yatse/lib:/home/mythtv:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/lib/python3.7/site-packages
2019-10-16 10:35:03.138 T:195225 DEBUG: CPythonInvoker(13, /home/mythtv/.kodi/addons/script.yatse.kodi/default.py): entering source directory /home/mythtv/.kodi/addons/script.yatse.kodi
2019-10-16 10:35:03.138 T:195225 DEBUG: CPythonInvoker(13, /home/mythtv/.kodi/addons/script.yatse.kodi/default.py): instantiating addon using automatically obtained id of "script.yatse.kodi" dependent on version 2.1.0 of the xbmc.python api
2019-10-16 10:35:03.150 T:195225 ERROR: 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 'private'
Traceback (most recent call last):
File "/home/mythtv/.kodi/addons/script.yatse.kodi/default.py", line 8, in <module>
from lib import share, stream, utils
File "/home/mythtv/.kodi/addons/script.yatse.kodi/lib/share.py", line 4, in <module>
import private.ydlfix
ModuleNotFoundError: No module named 'private'
-->End of Python script error report<--
2019-10-16 10:35:03.162 T:195027 DEBUG: ------ Window Init (DialogNotification.xml) ------
2019-10-16 10:35:03.221 T:195225 INFO: Python script stopped
2019-10-16 10:35:03.221 T:195225 DEBUG: Thread LanguageInvoker 140116555179776 terminating
Seeing the number of complains in the last part of that PR I guess there could be more changes.
Anyway I'll try to look into it, but the error sounds odd, it says it can't find a file that is present, I'm no Python expert so not sure I'll know what to do and how to support all Kodi versions :(
May require some external help
So after some quick tests it seems the python version embedded in Windows lack things.
Error Type: <class 'ModuleNotFoundError'>
Error Contents: No module named '_ctypes'
Will be a deal breaker as it breaks YoutubeDL :( Let's hope someone can report to them and get it fixed at some point.
I'm using Linux, fwiw, and am not seeing that error.
Yes the error appears after fixing other things.
Update the share.py import private.ydlfix
and change it to import lib.private.ydlfix
there's many other things required, but that should trigger the YoutubeDL error if it's present on linux too.
But Kodi build system is ugly as each OS and distrib have different embedded things or not and load different things leading to tons of different behaviors :(
On linux it will depends if libffi-dev is installed or not.
Could you push a new version, or a branch, with these changes so I can test them and perhaps help?
The only change to trigger that other issue is to edit the share.py
And change the import with
# -*- coding: utf-8 -*-
import urllib
import lib.private.ydlfix
import urlresolver
import utils
import xbmc
import xbmcaddon
from lib.utils import logger
from lib.youtube_dl import YoutubeDL
Basically just adding the lib. this will trigger the youtube dl issue with the _ctypes if it's present on your OS.
The rest require a tons more changes as UrlResolver also don't support python 3 and I use other things that I need to update.
But if on Linux you also get the _ctypes errors then it's a big problem.
With those changes, I get an error regarding urlparse
:
2019-10-16 15:03:59.286 T:335182 DEBUG: CPythonInvoker(20, /home/mythtv/.kodi/addons/script.yatse.kodi/default.py): instantiating addon using automatically obtained id of "script.yatse.kodi" dependent on version 2.1.0 of the xbmc.python api
2019-10-16 15:03:59.708 T:335182 ERROR: 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 'urlparse'
Traceback (most recent call last):
File "/home/mythtv/.kodi/addons/script.yatse.kodi/default.py", line 8, in <module>
from lib import share, stream, utils
File "/home/mythtv/.kodi/addons/script.yatse.kodi/lib/share.py", line 5, in <module>
import urlresolver
File "/home/mythtv/.kodi/addons/script.module.urlresolver.yatse/lib/urlresolver/__init__.py", line 31, in <module>
import urlparse
ModuleNotFoundError: No module named 'urlparse'
-->End of Python script error report<--
Ok so this is good news only pre packaged Python for Windows is wrong, let's hope someone can report to them so they fix that part.
I'll look into the others issues when I find some times.
Pushed 1.8.0 that should fix the issues on OS with proper Python integration.
No workaround for Windows broken builds.
Using 1.8.0, I now get a different error:
2019-10-18 10:41:35.752 T:953270 DEBUG: CPythonInvoker(35, /home/mythtv/.kodi/addons/script.yatse.kodi/default.py): start processing
2019-10-18 10:41:35.766 T:953270 DEBUG: -->Python Interpreter Initialized<--
2019-10-18 10:41:35.766 T:953270 DEBUG: CPythonInvoker(35, /home/mythtv/.kodi/addons/script.yatse.kodi/default.py): the source file to load is "/home/mythtv/.kodi/addons/script.yatse.kodi/default.py"
2019-10-18 10:41:35.767 T:953270 DEBUG: CPythonInvoker(35, /home/mythtv/.kodi/addons/script.yatse.kodi/default.py): setting the Python path to /home/mythtv/.kodi/addons/script.yatse.kodi:/home/mythtv/.kodi/addons/plugin.video.youtube/resources/lib/:/home/mythtv/.kodi/addons/script.module.certifi/lib:/home/mythtv/.kodi/addons/script.module.chardet/lib:/home/mythtv/.kodi/addons/script.module.idna/lib:/home/mythtv/.kodi/addons/script.module.inputstreamhelper/lib:/home/mythtv/.kodi/addons/script.module.kodi-six/libs:/home/mythtv/.kodi/addons/script.module.python.twitch/resources/lib:/home/mythtv/.kodi/addons/script.module.requests/lib:/home/mythtv/.kodi/addons/script.module.six/lib:/home/mythtv/.kodi/addons/script.module.urllib3/lib:/home/mythtv/.kodi/addons/script.module.urlresolver.yatse/lib:/home/mythtv:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/lib/python3.7/site-packages
2019-10-18 10:41:35.767 T:953270 DEBUG: CPythonInvoker(35, /home/mythtv/.kodi/addons/script.yatse.kodi/default.py): entering source directory /home/mythtv/.kodi/addons/script.yatse.kodi
2019-10-18 10:41:35.767 T:953270 DEBUG: CPythonInvoker(35, /home/mythtv/.kodi/addons/script.yatse.kodi/default.py): instantiating addon using automatically obtained id of "script.yatse.kodi" dependent on version 2.1.0 of the xbmc.python api
2019-10-18 10:41:36.178 T:953270 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <class 'ImportError'>
Error Contents: cannot import name '_subprocess' from 'subprocess' (/usr/lib/python3.7/subprocess.py)
Traceback (most recent call last):
File "/home/mythtv/.kodi/addons/script.yatse.kodi/lib/private/ydlfix.py", line 84, in patch_youtube_dl
import _subprocess
ModuleNotFoundError: No module named '_subprocess'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mythtv/.kodi/addons/script.yatse.kodi/default.py", line 8, in <module>
from lib import share, stream, utils
File "/home/mythtv/.kodi/addons/script.yatse.kodi/lib/share.py", line 9, in <module>
lib.private.ydlfix.patch_youtube_dl()
File "/home/mythtv/.kodi/addons/script.yatse.kodi/lib/private/ydlfix.py", line 87, in patch_youtube_dl
from subprocess import _subprocess
ImportError: cannot import name '_subprocess' from 'subprocess' (/usr/lib/python3.7/subprocess.py)
-->End of Python script error report<--
Hum yes forget to change this one but this is strange this is supposed to be an hack for UWP builds and UWP build do not support Python3 for now so did not get to that part of the code.
Can you change the last line of ydlfix.py
to read from lib.private.subprocess import _subprocess
and confirm it works?
That change did it! I'm now able to send a YouTube video using Yatse and Kodi plays it
Thanks, pushed 1.8.1 with the fix, but this is not normal that this fix is needed on Linux so there's something strange on the Python 3 for linux too :(
And Windows is still non working but https://forum.kodi.tv/showthread.php?tid=348495 it seems some teams members are now aware of that issue so it will probably be fixed at some point.
Leaving the issue opened so others see it and don't open new ones :)
Closing this as they finally fixed the Windows issues in recent Matrix builds.