I am afraid chatGPT does not provide any solution (as usual...), it just catch the error so that the program does not break and at the end proposes a default user or "handle differently" but we need to get your current user and "pi" is not an option because you may been using a custom user:
except KeyError: # PKEXEC_UID not set
# Additional fallback logic here if necessary
self.user = 'pi' # Fallback to a default user or handle differently
The problem is that PKEXEC_UID is not set in your system and I have never seen that. You will have more errors on other scripts for sure.
I have seen similar errors when you mix compiled python packages and debian python packages. I would use a new SD with a fresh install to see if the same error occurs before and after installing the extra packages you installed.
except KeyError: # PKEXEC_UID not set
# Additional fallback logic here if necessary
self.user = 'pi' # Fallback to a default user or handle differently
The problem is that PKEXEC_UID is not set in your system and I have never seen that. You will have more errors on other scripts for sure.
I have seen similar errors when you mix compiled python packages and debian python packages. I would use a new SD with a fresh install to see if the same error occurs before and after installing the extra packages you installed.