OSMC Setting Service failed to Launch [SOLVED]

Running kodi on a Raspberry Pi 2 Model B.
Have not used it for a week or two but now all my video addons fail to launch
and so does MyOSMC.

If I click the MyOSMC button a message says
“OSMC setting service failed to launch”

I still have access to kodi via SSH.
What I’ve tried so far (via SSH)
sudo apt-get update
sudo apt-get dist-upgrade
reboot

Moved ~/.kodi tp ~/kodi_backup
Rebooted

The new set of logs grab-logs -A uploaded:

https://paste.osmc.tv/obehixalip

Also tried:
sudo service mediacenter stop
sudo /usr/bin/mediacenter

kod starts but terminal displays
unknown
unknown
unknown
unknown

no more error messages when I start to press the MyOSMC button but still the same
“OSMC settings service failed to launch” is displayed on TV

I have a couple of extra programs added including python3, mpc, mplayer.
Previously I have run (about a year ago)
sudo apt-get update

so probably have borked something.
Any way to repair via SSH or am I looking at a reinstall?
My old post was related to

the sudoers file.
Thanks in advance.

Hi,

ERROR: CSettings: unable to load settings from special://masterprofile/guisettings.xml, creating new default settings

It looks to me like the data on sd card has become corrupted, I would try a reinstall; if issues persist replace the sd card.

Thanks Tom.

I did an fsck on the SD card checks out ok, but think I found the error from the pastebin:

19:52:02.027 T:1741681648 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<–
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type ‘exceptions.SyntaxError’>
Error Contents: ("Non-ASCII character ‘\xf2’ in file /usr/lib/python2.7/cookielib.py on line 749, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details", (’/usr/lib/python2.7/cookielib.py’, 749, 0, None))
Traceback (most recent call last):
File “/usr/share/kodi/addons/service.osmc.settings/service.py”, line 26, in
import resources.lib.osmc_main as m
File “/usr/share/kodi/addons/service.osmc.settings/resources/lib/osmc_main.py”, line 52, in
import osmc_walkthru
File “/usr/share/kodi/addons/service.osmc.settings/resources/lib/osmc_walkthru.py”, line 11, in
import requests
File “/usr/lib/python2.7/dist-packages/requests/init.py”, line 80, in
from . import utils
File “/usr/lib/python2.7/dist-packages/requests/utils.py”, line 25, in
from .compat import parse_http_list as _parse_list_header
File “/usr/lib/python2.7/dist-packages/requests/compat.py”, line 91, in
import cookielib
SyntaxError: (“Non-ASCII character ‘\xf2’ in file /usr/lib/python2.7/cookielib.py on line 749, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details”, (’/usr/lib/python2.7/cookielib.py’, 749, 0, None))
–>End of Python script error report<–

An exception error.
I viewed the contents of /sur/lib/python2.7/cookielib.py
and at line 748:

    # normalise case, as per RFC 2965 secti^?. 3.3.3

( ! self.domain = domain.loweò()
self.d/main_specified = domain_specified^Z # SIgè. W% nded to know whether the dooain given in the
$ # cookie-attribute had an initial tot, in order to follow RFC 2965
# has clarified ij dvaft e2rata). Needed for phe returned $Domain
^@ # van5e.

Indeed line 749 contains non ASCII character.
Question is, is this normal ??

Not sure if I can reinstall python 2.7 or this one file?
If anyone can compare their cookielib.py at line 749 it would eliminate this file.

I’m preparing to reinstall just in case it cant be fixed

Here’s the block of code where your file corruption has occurred:

self.version = version
self.name = name
self.value = value
self.port = port
self.port_specified = port_specified
# normalise case, as per RFC 2965 section 3.3.3
self.domain = domain.lower()
self.domain_specified = domain_specified
# Sigh.  We need to know whether the domain given in the
# cookie-attribute had an initial dot, in order to follow RFC 2965
# (as clarified in draft errata).  Needed for the returned $Domain
# value.
self.domain_initial_dot = domain_initial_dot
self.path = path
self.path_specified = path_specified
self.secure = secure
self.expires = expires
self.discard = discard
self.comment = comment
self.comment_url = comment_url
self.rfc2109 = rfc2109

If you want to reinstall the bad file, it’s in package libpython2.7-stdlib, not in python2.7.

I’ve managed to fix it this time by the skin of my teeth.
I have a second raspberry Pi 2 running Debian 8. I compared file sizes and cookielib.py was the exact
same file size in bytes.
I copied over the same file, rebooted and after a few tense seconds, everything is ok again.

Next time i wont be so lucky. This is probably the result of running apt-get upgrade at some earlier
point in time, Ive appended the first post [solved] to save everybody reading it again.

Thanks for this, I just got it working again and marked it solved, however as my file came from Debain8,
not OSMC it may be worth reinstalling libpython2.7-stdlib just to make sure.

OSMC also uses Debian.