Hallo,
mein Setup:
RPi "Stretch"
Python 3.10.0
pi@raspberrypi:/opt/fhem/log $ python --version
Python 3.10.0
pi@raspberrypi:/opt/fhem/log $ python3 --version
Python 3.10.0
list fhempy-Server:
Internals:
DEF 0
FD 168
FUUID 6188470f-f33f-9382-75a5-11de59070d3ae53c
LAST_START 2021-11-07 23:34:09
LAST_STOP 2021-11-07 23:34:09
NAME fhempyserver_15733
NR 2461
NTFY_ORDER 50-fhempyserver_15733
PID 7034
STARTS 22
STATE ???
TYPE fhempyServer
currentlogfile ./log/fhempy-2021-11-07.log
logfile ./log/fhempy-%Y-%m-%d.log
CoProcess:
cmdFn fhempyServer_getCmd
name fhempy
state running FHEM/bindings/python/bin/fhempy
READINGS:
2021-11-07 23:34:09 fhempy running FHEM/bindings/python/bin/fhempy
Attributes:
devStateIcon { my $status_img = "10px-kreis-gruen";; my $status_txt = "running";; if (substr(ReadingsVal($name, "fhempy", "running"),0,7) ne "running") { $status_img = "10px-kreis-rot";; $status_txt = "stopped";; } "<div><a>".FW_makeImage($status_img, $status_txt)."</a><a href=\"/fhem?cmd.dummy=set $name restart&XHR=1\" title=\"Restart\">".FW_makeImage("audio_repeat")."</a></div>" }
group fhempy
icon python
logfile ./log/fhempy-%Y-%m-%d.log
nrarchive 10
room fhempy
local_pybinding zeigt den fhempy Server als offline an:
Internals:
BindingType fhempy
DEF fhempy
DeviceName ws:127.0.0.1:15733
FUUID 6188470f-f33f-9382-a5a1-d1d10b952221e26c
IP 127.0.0.1
NAME local_pybinding
NEXT_OPEN 1636323200.2308
NR 2460
NTFY_ORDER 50-local_pybinding
PARTIAL
PORT 15733
STATE fhempy server offline
TYPE BindingsIo
localBinding 1
nextOpenDelay 10
READINGS:
2021-11-07 23:13:12 state fhempy server offline
args:
local_pybinding
BindingsIo
fhempy
argsh:
Attributes:
devStateIcon { my $status_img = "10px-kreis-gruen";; my $status_txt = "connected";; if (ReadingsVal($name, "state", "disconnected") eq "disconnected") { $status_img = "10px-kreis-rot";; $status_txt = "disconnected";; } my $ver = ReadingsVal($name, "version", "-");; "<div><a>".FW_makeImage($status_img, $status_txt)."</a><a> ".$ver." </a><a href=\"/fhem?cmd.dummy=set $name update&XHR=1\" title=\"Start update\">".FW_makeImage("refresh")."</a></div>" }
group fhempy
icon file_json-ld2
room fhempy
Sowohl der Server als auch local_pybinding werden als "grün" angezeigt. local_pybinding allerdings erst, als ich set <...> update durchgeführt habe.
Das fhempy Log File zeigt mir folgende Fehler:
2021-11-07 23:38:44,879 - WARNING - __main__: Failed to load fhempy: No module named 'fhempy'
2021-11-07 23:38:44,880 - INFO - __main__: Attempting install of fhempy>=0.1.12
2021-11-07 23:38:50,279 - ERROR - __main__: Unable to install package fhempy>=0.1.12: ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 173, in _main
status = self.run(options, args)
File "/usr/local/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 203, in wrapper
return func(self, options, args)
File "/usr/local/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 266, in run
session = self.get_default_session(options)
File "/usr/local/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 74, in get_default_session
self._session = self.enter_context(self._build_session(options))
File "/usr/local/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 88, in _build_session
session = PipSession(
File "/usr/local/lib/python3.10/site-packages/pip/_internal/network/session.py", line 289, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.10/site-packages/pip/_internal/network/session.py", line 132, in user_agent
linux_distribution = distro.linux_distribution() # type: ignore
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/distro.py", line 125, in linux_distribution
return _distro.linux_distribution(full_distribution_name)
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/distro.py", line 681, in linux_distribution
self.version(),
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/distro.py", line 741, in version
self.lsb_release_attr('release'),
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/distro.py", line 903, in lsb_release_attr
return self._lsb_release_info.get(attribute, '')
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/distro.py", line 556, in __get__
ret = obj.__dict__[self._fname] = self._f(obj)
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/distro.py", line 1014, in _lsb_release_info
stdout = subprocess.check_output(cmd, stderr=devnull)
File "/usr/local/lib/python3.10/subprocess.py", line 420, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/local/lib/python3.10/subprocess.py", line 524, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
Traceback (most recent call last):
File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
Nach etlichen Versionen und Löschen/erneutes Anlegen fehlt mir eine kreative Idee. Danke.
Zwischenstand:
Nach Prüfung der fhempy-Log Datei:
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
habe ich festgestellt, dass auf meinem RPi auch manuell der Befehl lsb_release fehlschlägt.
Nach Recherche habe ich folgende Datei angepasst:
pi@raspberrypi:/usr/bin $ sudo vi lsb_release
Die erste Zeile habe ich wie folgt geändert:
# !/usr/bin/python3.5 -Es
Der Fehler war gelöst, bist der nächste auftauchte:
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
2021-11-08 18:03:39,896 - ERROR - __main__: Failed to install fhempy, exit now...
Nach Recherche war dieser Fehler bekannt und man musste nur einige Libraries nachinstallieren und Python 3.10.0 neu kompilieren.
sudo apt install libssl-dev
sudo apt install libncurses5-dev
sudo apt install libsqlite3-dev
sudo apt install libreadline-dev
sudo apt install libtk8.6
sudo apt install libgdm-dev
sudo apt install libdb4o-cil-dev
sudo apt install libpcap-dev
Das erneute make führte allerdings zu Fehlern. Eine erneute Recherche brachte mich darauf, dass 3.10.0 auf Stretch grundsätzlich zu Problemen führt. Das hat mich zur Entscheidung geführt, entweder 3.9.5 (bestätigt OK) oder auf Bullseye zu wechseln.
Nach Abwägung aller Abhängigkeiten gehe ich jetzt auf Python 3.9.5.
More to come...
Warum aktualisierst du nicht einfach auf bullseye? Mit den manuellen Installationen verbiegst du dir sonst das ganze System.
In der Tat scheint die Kombi mit Stretch problematisch zu sein. Hintergrund sind vermutlich Themen mit den Python Versionen.
Nachdem ich nun folgende Upgrade durchgeführt habe:
Stretch -> Buster und
Buster -> Bullseye
bekame ich angezeigt, dass die Datei /opt/fhem/.local vorhanden ist (und leer ist) und nicht überschrieben werden kann.
pi@raspberrypi:/opt/fhem $ ls .local
.local
pi@raspberrypi:/opt/fhem $ vi .local
pi@raspberrypi:/opt/fhem $ rm .local
Und siehe da, es geht weiter:
pi@raspberrypi:/opt/fhem/log $ vi fhempy-2021-11-10.log
2021-11-10 13:37:55,444 - INFO - fhempy.lib.fhem_pythonbinding: Starting fhempy...
2021-11-10 13:37:55,481 - INFO - fhempy.lib.pkg_installer: Attempting install of async-upnp-client==0.20.0
2021-11-10 13:38:09,760 - INFO - fhempy.lib.pkg_installer: Successfully installed async-upnp-client==0.20.0 update!
2021-11-10 13:38:09,768 - INFO - fhempy.lib.fhem_pythonbinding: Waiting for FHEM connection
2021-11-10 13:38:09,914 - WARNING - asyncio: Executing <Task pending name='Task-1' coro=<async_main() running at /opt/fhem/.local/lib/python3.9/site-packages/fhempy/lib/fhem_pythonbinding.py:530> wait_for=<_GatheringFuture pending cb=[<TaskWakeupMethWrapper object at 0x7463cdd8>()] created at /usr/local/lib/python3.9/asyncio/tasks.py:704> cb=[_run_until_complete_cb() at /usr/local/lib/python3.9/asyncio/base_events.py:184] created at /usr/local/lib/python3.9/asyncio/base_events.py:621> took 0.145 seconds
2021-11-10 13:38:09,922 - INFO - websockets.server: server listening on 0.0.0.0:15733
2021-11-10 13:37:55,444 - INFO - fhempy.lib.fhem_pythonbinding: Starting fhempy...
2021-11-10 13:37:55,481 - INFO - fhempy.lib.pkg_installer: Attempting install of async-upnp-client==0.20.0
2021-11-10 13:38:09,760 - INFO - fhempy.lib.pkg_installer: Successfully installed async-upnp-client==0.20.0 update!
2021-11-10 13:38:09,768 - INFO - fhempy.lib.fhem_pythonbinding: Waiting for FHEM connection
2021-11-10 13:38:09,914 - WARNING - asyncio: Executing <Task pending name='Task-1' coro=<async_main() running at /opt/fhem/.local/lib/python3.9/site-packages/fhempy/lib/fhem_pythonbinding.py:530> wait_for=<_GatheringFuture pending cb=[<TaskWakeupMethWrapper object at 0x7463cdd8>()] created at /usr/local/lib/python3.9/asyncio/tasks.py:704> cb=[_run_until_complete_cb() at /usr/local/lib/python3.9/asyncio/base_events.py:184] created at /usr/local/lib/python3.9/asyncio/base_events.py:621> took 0.145 seconds
2021-11-10 13:38:09,922 - INFO - websockets.server: server listening on 0.0.0.0:15733
Trotzdem wird noch kein laufender fhempy Server gemeldet:
Internals:
BindingType fhempy
CFGFN
DEF fhempy
DeviceName ws:127.0.0.1:15733
FUUID 618bad14-f33f-9382-f8ce-66a69739911a653c
IP 127.0.0.1
NAME local_pybinding
NEXT_OPEN 1636543953.20931
NR 2903
NTFY_ORDER 50-local_pybinding
PARTIAL
PORT 15733
STATE fhempy server offline
TYPE BindingsIo
localBinding 1
nextOpenDelay 10
READINGS:
2021-11-10 13:46:57 state fhempy server offline
args:
local_pybinding
BindingsIo
fhempy
argsh:
Attributes:
devStateIcon { my $status_img = "10px-kreis-gruen";; my $status_txt = "connected";; if (ReadingsVal($name, "state", "disconnected") eq "disconnected") { $status_img = "10px-kreis-rot";; $status_txt = "disconnected";; } my $ver = ReadingsVal($name, "version", "-");; "<div><a>".FW_makeImage($status_img, $status_txt)."</a><a> ".$ver." </a><a href=\"/fhem?cmd.dummy=set $name update&XHR=1\" title=\"Start update\">".FW_makeImage("refresh")."</a></div>" }
group fhempy
icon file_json-ld2
room fhempy
verbose 5
Nach einem Neustart des kompletten Systems, funktioniert es nun.
Für alle, die ähnliche Probleme haben:
a) Bullseye ist eine gute Basis, um mit fhempy zu starten
b) Einzelne Probleme sind gut zu lösen, wenn verbose=5 und durch lesen der fhempy Log Files
Danke für die Anregungen und das sehr gute Modul...