Win Beautifulsoup 4 doenst work with Kodi 20.3
#1
Hi all,

I have a Problem with Kodi 20.3 with BS4.

I add in Addon.xml this Code.
:
    <import addon="script.module.beautifulsoup4" />

In my Default.py added :

Code:
from bs4 import BeautifulSoup4

I installed BeautifulSoap 4.12.2 and check it in System-->Addons ---> Manage.. ---> and it is activated and listed.

But I only get the log Error Massage :

Code:
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'ImportError'>
                                                   Error Contents: cannot import name 'BeautifulSoup4' from 'bs4' (C:\Users\.........\Kodi\addons\script.module.beautifulsoup4\lib\bs4\__init__.py)
                                                   Traceback (most recent call last):
                                                     File "C:\Users\.........\Roaming\Kodi\addons\............\default.py", line 14, in <module>
                                                       from bs4 import BeautifulSoup4
                                                   ImportError: cannot import name 'BeautifulSoup4' from 'bs4' (C:\Users\........\AppData\Roaming\Kodi\addons\script.module.beautifulsoup4\lib\bs4\__init__.py)
                                                   -->End of Python script error report<--

I can not install another version of bs4. Only 4.12.2 is possible by Nexus 20.3 x64.

Thx a lot.

Best Regards.
Reply
#2
python:
from bs4 import BeautifulSoup
Reply
#3
same error
Reply
#4
How about this?
python:
import bs4 as BeautifulSoup
Reply
#5
(2024-01-23, 20:15)mumati Wrote: same error

Can we see full debug log where
python:
from bs4 import BeautifulSoup
fails?
Reply
#6
Hi again,

I send all the Information again with all the possibility.

in my Addon is :

Addon.xml:
    <import addon="script.module.beautifulsoup" version="3.2.1"/>
    <import addon="script.module.beautifulsoup4" />

Default.py

default.py:

from BeautifulSoup import BeautifulStoneSoup, BeautifulSoup, BeautifulSOAP

Error :
kodi error:
2024-01-27 12:15:03.364 T:4060    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 'BeautifulSoup'
                                                   Traceback (most recent call last):
                                                     File "C:\Users\........AppData\Roaming\Kodi\addons\plugin.video.live.muco\default.py", line 14, in <module>
                                                       from BeautifulSoup import BeautifulStoneSoup, BeautifulSoup, BeautifulSOAP
                                                   ModuleNotFoundError: No module named 'BeautifulSoup'
                                                   -->End of Python script error report<--


Installed BeautifulSoup is this here :

Beautifulsoup:
https://mirrors.kodi.tv/addons/matrix/sc...4.12.2.zip

Also tried with import from bs4 or from BeautifulSoup or BeautifulSoup4

Always same error. I think, anything else doenst work.
Reply
#7
So now default.py

default.py:
from bs4 import BeautifulStoneSoup, BeautifulSoup, BeautifulSOAP

Error :

Kodi Error:
2024-01-27 12:27:47.292 T:14548   error <general>: 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 'BeautifulSOAP' from 'bs4' (C:\Users\......AppData\Roaming\Kodi\addons\script.module.beautifulsoup4\lib\bs4\__init__.py)
                                                   Traceback (most recent call last):
                                                     File "C:\Users\.........AppData\Roaming\Kodi\addons\plugin.video.live.muco\default.py", line 14, in <module>
                                                       from bs4 import BeautifulStoneSoup, BeautifulSoup, BeautifulSOAP
                                                   ImportError: cannot import name 'BeautifulSOAP' from 'bs4' (C:\Users\.......AppData\Roaming\Kodi\addons\script.module.beautifulsoup4\lib\bs4\__init__.py)
                                                   -->End of Python script error report<--
Reply
#8
cannot import name 'BeautifulSOAP'

there is definitely no BeautifulSOAP in the bs4 addon
considering i don't know what that is and google doesn't seem to either are you certain you're using it as intended?
Reply
#9
Thx a lot. I think, I must change all the codes in my addon and try with another way. I used it with kodi 18 without any problem.

default.py:

        if isinstance(data,BeautifulSOAP):
            if data.find('channels_info'):
                media_info = data.channels_info
            elif data.find('items_info'):
                media_info = data.items_info
        if media_info:
            source_media = {}
            source_media['url'] = source_url
            try: source_media['title'] = media_info.title.string
            except: pass
            try: source_media['thumbnail'] = media_info.thumbnail.string
            except: pass
            try: source_media['fanart'] = media_info.fanart.string
            except: pass
            try: source_media['genre'] = media_info.genre.string
            except: pass
            try: source_media['description'] = media_info.description.string
            except: pass
            try: source_media['date'] = media_info.date.string
            except: pass
            try: source_media['credits'] = media_info.credits.string
            except: pass



and

default.py:

if '<SetViewMode>' in data:
            try:
                viewmode=re.findall('<SetViewMode>(.*?)<',data)[0]
                xbmc.executebuiltin("Container.SetViewMode(%s)"%viewmode)
                print('done setview',viewmode)
            except: pass
        return BeautifulSOAP(data, convertEntities=BeautifulStoneSoup.XML_ENTITIES)

It was so ok with python 2 and bs2. I think I learn a little bit more bs4 and write the codes with another way.

Many thanks.
Reply
#10
Again if you have errors importing from a package or standard module need to see the Kodi debug log where python is invoked in Kodi.  Just showing the exception and your code doesn't really help at this stage.

scott s.
.
Reply

Logout Mark Read Team Forum Stats Members Help
Beautifulsoup 4 doenst work with Kodi 20.30