DrozmotiX / ioBroker.esphome

Control your ESP8266/ESP32 with simple yet powerful configuration files created and managed by ESPHome
MIT License
30 stars 23 forks source link

ESPHome Dashboard doesn't start, Fatal Python error: init_fs_encoding #209

Closed JonasRueter closed 3 months ago

JonasRueter commented 3 months ago

!!! Before you start !!!

Describe the bug
When starting the adapter, a python error appears in log file (see down in Logs). The dashboard does not work, Regardless if I'm trying to include it in ioBroker or use a browser to access http://ip.of.my.iobroker:6052 Finding / adding devices in settings works though.

To Reproduce
Steps to reproduce the behavior: Installed ESPHome on my ioBroker and tried to start it. Tried a new installation, got to the same issue. Tried various fixes that were recommended on the web, none on them changed something

What I tried as solutions already Unset PHYTONHOME and PYTHONPATH as recommended here re-installed python sudo apt install --reinstall python3-full python3.11-dev libpython3.11-dev python3-pip re installed all output of sudo apt-get install --reinstall $(dpkg -S '/usr/lib/python3*' | cut -d ':' -f1 | cut -d ',' -f1 | sort | uniq | tr '\n' ' ')

Also I created a new venv with python3 -m venv venv, activated it with source venv/bin/activate, installed pip3 install esphome and checked esphome version what returned Version: 2024.7.0 (how would I get into the venv ioBroker is using?)

Expected behavior
Dashboard on ioBroker should work ;)

Logs (as screenshot and in text-form)

host.ioBroker | 2024-07-23 11:15:38.248 | info | instance system.adapter.esphome.0 terminated with code 11 (ADAPTER_REQUESTED_TERMINATION)
-- | -- | -- | --
host.ioBroker | 2024-07-23 11:15:40.844 | info | instance system.adapter.esphome.0 started with pid 9706
esphome.0 | 2024-07-23 11:15:42.306 | debug | Redis Objects: Use Redis connection: 127.0.0.1:9001
esphome.0 | 2024-07-23 11:15:42.347 | debug | Objects client ready ... initialize now
esphome.0 | 2024-07-23 11:15:42.349 | debug | Objects create System PubSub Client
esphome.0 | 2024-07-23 11:15:42.351 | debug | Objects create User PubSub Client
esphome.0 | 2024-07-23 11:15:42.403 | debug | Objects client initialize lua scripts
esphome.0 | 2024-07-23 11:15:42.411 | debug | Objects connected to redis: 127.0.0.1:9001
esphome.0 | 2024-07-23 11:15:42.460 | debug | Redis States: Use Redis connection: 127.0.0.1:9000
esphome.0 | 2024-07-23 11:15:42.478 | debug | States create System PubSub Client
esphome.0 | 2024-07-23 11:15:42.479 | debug | States create User PubSub Client
esphome.0 | 2024-07-23 11:15:42.547 | debug | States connected to redis: 127.0.0.1:9000
esphome.0 | 2024-07-23 11:15:42.592 | debug | Plugin sentry Initialize Plugin (enabled=true)
esphome.0 | 2024-07-23 11:15:43.036 | info | starting. Version 0.5.0-beta.8 in /opt/iobroker/node_modules/iobroker.esphome, node: v18.20.4, js-controller: 5.0.19
esphome.0 | 2024-07-23 11:15:43.148 | info | Native Integration of ESPHome Dashboard enabled
esphome.0 | 2024-07-23 11:15:43.679 | info | [Error caught and send to Sentry, thank you collaborating!] error: Error: Command failed with exit code 1: /home/iobroker/.cache/autopy/python/3.11.9/bin/python3 -m venv /home/iobroker/.cache/autopy/venv/esphomePython path configuration: PYTHONHOME = (not set) PYTHONPATH = (not set) program name = '/home/iobroker/.cache/autopy/python/3.11.9/bin/python3' isolated = 0 environment = 1 user site = 1 safe_path = 0 import site = 1 is in build tree = 0 stdlib dir = '/home/iobroker/.cache/autopy/python/3.11.9/lib/python3.11' sys._base_executable = '/home/iobroker/.cache/autopy/python/3.11.9/bin/python3' sys.base_prefix = '/home/iobroker/.cache/autopy/python/3.11.9' sys.base_exec_prefix = '/home/iobroker/.cache/autopy/python/3.11.9' sys.platlibdir = 'lib' sys.executable = '/home/iobroker/.cache/autopy/python/3.11.9/bin/python3' sys.prefix = '/home/iobroker/.cache/autopy/python/3.11.9' sys.exec_prefix = '/home/iobroker/.cache/autopy/python/3.11.9' sys.path = [ '/home/iobroker/.cache/autopy/python/3.11.9/lib/python311.zip', '/home/iobroker/.cache/autopy/python/3.11.9/lib/python3.11', '/home/iobroker/.cache/autopy/python/3.11.9/lib/python3.11/lib-dynload', ]Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encodingPython runtime state: core initializedLookupError: no codec search functions registered: can't find encodingCurrent thread 0x0000007f931ed040 (most recent call first): <no Python frame> at makeError (file:///opt/iobroker/node_modules/autopy/node_modules/execa/lib/error.js:60:11) at handlePromise (file:///opt/iobroker/node_modules/autopy/node_modules/execa/index.js:124:26) at processTicksAndRejections (node:internal/process/task_queues:95:5) at $df9eabe9bda49ea8$export$e522f41234ab669a (file:///opt/iobroker/node_modules/autopy/src/index.ts:228:9) at Esphome.espHomeDashboard (/opt/iobroker/node_modules/iobroker.esphome/main.js:110:19) at Esphome.onReady (/opt/iobroker/node_modules/iobroker.esphome/main.js:78:5)
esphome.0 | 2024-07-23 11:15:48.155 | info | Bonjour service started, new devices will be detected automatically

Better readable output from my own venv:

(venv) jonas@ioBroker:~ $ /home/iobroker/.cache/autopy/python/3.11.9/bin/python3 -m venv /home/iobroker/.cache/autopy/venv/esphome
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = '/home/iobroker/.cache/autopy/python/3.11.9/bin/python3'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/home/iobroker/.cache/autopy/python/3.11.9/lib/python3.11'
  sys._base_executable = '/home/iobroker/.cache/autopy/python/3.11.9/bin/python3'
  sys.base_prefix = '/home/iobroker/.cache/autopy/python/3.11.9'
  sys.base_exec_prefix = '/home/iobroker/.cache/autopy/python/3.11.9'
  sys.platlibdir = 'lib'
  sys.executable = '/home/iobroker/.cache/autopy/python/3.11.9/bin/python3'
  sys.prefix = '/home/iobroker/.cache/autopy/python/3.11.9'
  sys.exec_prefix = '/home/iobroker/.cache/autopy/python/3.11.9'
  sys.path = [
    '/home/iobroker/.cache/autopy/python/3.11.9/lib/python311.zip',
    '/home/iobroker/.cache/autopy/python/3.11.9/lib/python3.11',
    '/home/iobroker/.cache/autopy/python/3.11.9/lib/python3.11/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
LookupError: no codec search functions registered: can't find encoding

Current thread 0x0000007fac5d4040 (most recent call first):
  <no Python frame>

Versions:

Additional context

SimonFischer04 commented 3 months ago

@JonasRueter

Just did a clean new install here as well on a Pi4 and everything works for me still.

Tried a new installation, got to the same issue.

What do you mean by new installation? Newly formatted (sdcard) for pi with new iobroker, ... Just an adapter reinstall or iobroker reinstall or ...?

Also I created a new venv with python3 -m venv venv, activated it with source venv/bin/activate, installed pip3 install esphome and checked esphome version what returned Version: 2024.7.0

so using this you got a working dashboard?

(how would I get into the venv ioBroker is using?)

source /home/iobroker/.cache/autopy/venv/esphome/bin/activate

Operating system: Raspberry Pi 4 / Debian Bookworm

32bit or 64? We already had problems with 32bit a few times with things the adapter has nothing to do with / cant really fix.

SimonFischer04 commented 3 months ago

@JonasRueter If not completely new environment: have you already tried to clean the adapters cache: rm -rf /home/iobroker/.cache/autopy

what does this print?: cd / sudo find / -type d -name "encodings"

JonasRueter commented 3 months ago

@SimonFischer04

If not completely new environment: have you already tried to clean the adapters cache: rm -rf /home/iobroker/.cache/autopy

That one actually did the trick. Uninstalled the adapter, cleaned the cache, installed the adapter again. Thanks for your help!

Other answers as I already typed them and they might be useful for somebody in future time:

What do you mean by new installation? Newly formatted (sdcard) for pi with new iobroker, ... Just an adapter reinstall or iobroker reinstall or ...?

just the adapter.

Also I created a new venv with python3 -m venv venv, activated it with source venv/bin/activate, installed pip3 install esphome and checked esphome version what returned Version: 2024.7.0

so using this you got a working dashboard?

No, same error, that one actually brought me the better readable log

Operating system: Raspberry Pi 4 / Debian Bookworm

32bit or 64? We already had problems with 32bit a few times with things the adapter has nothing to do with / cant really fix.

64bit

what does this print?: cd / sudo find / -type d -name "encodings"

/opt/iobroker/node_modules/iconv-lite/encodings
/opt/iobroker/node_modules/zigbee-herdsman-converters/node_modules/iconv-lite/encodings
/opt/iobroker/node_modules/whatwg-encoding/node_modules/iconv-lite/encodings
/home/iobroker/.cache/autopy/python/3.11.9/lib/python3.11/encodings
/usr/share/fonts/X11/encodings
/usr/lib/python3.11/encodings
/usr/lib/node_modules/npm/node_modules/iconv-lite/encodings
SimonFischer04 commented 2 months ago

@JonasRueter

No, same error, that one actually brought me the better readable log

/home/iobroker/.cache/autopy/python/3.11.9/bin/python3 -m venv /home/iobroker/.cache/autopy/venv/esphome

If you just did this what i can read from your output above: you basically didn't create a new venv but just re-used the adapters one, which got broken for some reason

Other answers as I already typed them and they might be useful for somebody in future time:

Thanks for sharing

That one actually did the trick. Uninstalled the adapter, cleaned the cache, installed the adapter again. Thanks for your help!

Great to hear, no problem. Thanks for sharing what worked for you.

SimonFischer04 commented 2 months ago

Uninstalled the adapter, cleaned the cache, installed the adapter again.

PS (as it came up in Forum also): Unistall/reinstall should not be required. Just cleaning cache and reStarting adapter should have been enough. But reinstall also doesn't hurt, if you don't have anything configured yet.

SimonFischer04 commented 2 months ago

PS 2.: Created a new issue / feature request to track this and provide a button in the adapters config to do this cache cleaning, as it has come up a few times (recently)