Issue with Kotori on RaspberryPi (ARM)

Dear Andreas

Thanks for your investigations.
Yes i have Kotori 0.15.0 on a raspiPI
I have following this doc Setup on Debian — Kotori 0.22.7 documentation to install Kotori.
I try next Week-end to reinstall on a fresh raspbian.

Thanks, Georges! Will still be happy to help but currently I don’t have a RaspberryPi running on my workbench ¹.

However, I believe @Thias and maybe also @Alex run instances of Kotori on their RaspberryPi machines. So I’m humbly asking whether one of you experienced similar things like @georges.gagliano when ramping up your DAQ backend setup?


¹ Should really get one up and running again to build a fresh Kotori 0.21.1 package for ARM.

Is there a difference between install kotori on Jessie or Stretch ?
Because in doc, there is a lot of reference to Jessie but nothing on stretch.

Yeah, then the Kotori armhf package has probably been built on Debian Jessie. This would also match my personal memories. But as Kotori presumably does start successfully on Stretch, I assume this is actually not the problem.

It looks like it can’t load its own Python modules properly. However, the log output lacks information about what went wrong when trying to load the application entrypoint kotori.daq.application.mqttkit:mqttkit_application.

Would it be possible that I could log in to the machine to investigate the problem hands-on?

yes it’s possible !

Ok, then let’s continue using PM. I’ll send you my ssh public key. Maybe I can catch the error.

ok when i have our ssh key i open access to my raspberry

Problem

Thanks, we already found the problem. It is reproduceable by issuing:

root@Framboise1:~# su - kotori
kotori@Framboise1:~ $ /opt/kotori/bin/python
>>> import kotori.daq.application.mqttkit
[...]
  File "/opt/kotori/lib/python2.7/site-packages/influxdb/client.py", line 16, in <module>
    from influxdb.line_protocol import make_lines, quote_ident, quote_literal
  File "/opt/kotori/lib/python2.7/site-packages/influxdb/line_protocol.py", line 12, in <module>
    from pytz import UTC
ImportError: No module named pytz

Looks like the early Kotori 0.15.0 package lacks this dependency.

Investigation

We expected a simple

kotori@Framboise1:~ $ /opt/kotori/bin/pip install pytz

to work by just installing the pytz package.

pip itself is broken

However, the attempt to install the pytz package yields another error like

Traceback (most recent call last):
  File "/opt/kotori/bin/pip", line 7, in <module>
    from pip import main
  File "/opt/kotori/lib/python2.7/site-packages/pip/__init__.py", line 73, in <module>
    from pip.util import get_installed_distributions, get_prog
  File "/opt/kotori/lib/python2.7/site-packages/pip/util.py", line 20, in <module>
    from distlib import version
  File "/opt/kotori/lib/python-wheels/distlib-0.1.9-py2.py3-none-any.whl/distlib/version.py", line 14, in <module>
  File "/opt/kotori/lib/python-wheels/distlib-0.1.9-py2.py3-none-any.whl/distlib/compat.py", line 31, in <module>
ImportError: cannot import name HTTPSHandler

By following python - ImportError: cannot import name HTTPSHandler using PIP - Stack Overflow we also found that

import ssl

would also error out like

kotori@Framboise1:~ $ /opt/kotori/bin/python -mssl
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: libssl.so.1.0.0: cannot open shared object file: No such file or directory

So we conclude binary compatibility between Debian Jessie and Debian Stretch is not given due to conflicts regarding the OpenSSL version. In turn, this breaks pip completely.

Damn. We really should provide packages built on/for Debian Stretch.

Solution

So, let’s just download the single missing package pytz · PyPI from PyPI:

su - kotori
cd /tmp
wget https://files.pythonhosted.org/packages/af/be/6c59e30e208a5f28da85751b93ec7b97e4612268bb054d0dff396e758a90/pytz-2018.9.tar.gz
tar -xzf pytz-2018.9.tar.gz
cd pytz-2018.9/

and install it using the basic Python package setup mechanism without even touching pip at all:

/opt/kotori/bin/python setup.py install

Installed /opt/kotori/lib/python2.7/site-packages/pytz-2018.9-py2.7.egg
Processing dependencies for pytz==2018.9
Finished processing dependencies for pytz==2018.9

Proof

Start Kotori ad hoc in the foreground

su - kotori
/opt/kotori/bin/kotori --config /etc/kotori/kotori.ini
2019-03-02T03:09:33+0100 [kotori.core                  ] INFO: Enabling applications ['hives']
2019-03-02T03:09:33+0100 [kotori.core                  ] INFO: Starting application "hives"
2019-03-02T03:09:39+0100 [kotori.daq.graphing.grafana  ] INFO: Starting GrafanaManager "GrafanaManager". grafana=localhost:3000
2019-03-02T03:09:39+0100 [kotori.daq.services.mig      ] INFO: Starting MqttInfluxGrafanaService. name=service-mig-hives, channel={'realm': 'hives', 'mqtt_topics': 'hives/#', 'enable': 'true', 'type': 'application', 'application': 'kotori.daq.application.mqttkit:mqttkit_application'}
2019-03-02T03:09:39+0100 [kotori.daq.intercom.mqtt.base] INFO: Starting PahoMqttAdapter. name=mqtt-hives, broker=localhost:1883, object=<kotori.daq.intercom.mqtt.paho.PahoMqttAdapter object at 0x74319950>
2019-03-02T03:09:39+0100 [kotori.core                  ] INFO: Enabling vendors []
2019-03-02T03:09:39+0100 [kotori.daq.intercom.mqtt.paho] INFO: Subscribing to topics [u'hives/#']. client=<paho.mqtt.client.Client object at 0x74319b90>
2019-03-02T03:09:39+0100 [kotori.daq.intercom.mqtt.paho] INFO: Subscribing to topic 'hives/#'
2019-03-02T03:09:41+0100 [kotori.daq.services.mig      ] INFO: [hives       ] transactions: 0.00 tps
[...]
CTRL+C

Restart Kotori service

root@Framboise1:~# systemctl restart kotori

root@Framboise1:~# tail -F /var/log/kotori/kotori.log
2019-03-02T03:17:33+0100 [kotori                             ] INFO: Starting Kotori version 0.15.0
2019-03-02T03:17:33+0100 [kotori                             ] INFO: Using configuration file /etc/kotori/kotori.ini
2019-03-02T03:17:33+0100 [kotori.core                        ] INFO: Enabling applications ['hives']
2019-03-02T03:17:33+0100 [kotori.core                        ] INFO: Starting application "hives"
2019-03-02T03:17:34+0100 [kotori.daq.graphing.grafana        ] INFO: Starting GrafanaManager "GrafanaManager". grafana=localhost:3000
2019-03-02T03:17:34+0100 [kotori.daq.services.mig            ] INFO: Starting MqttInfluxGrafanaService. name=service-mig-hives, channel={'realm': 'hives', 'mqtt_topics': 'hives/#', 'enable': 'true', 'type': 'application', 'application': 'kotori.daq.application.mqttkit:mqttkit_application'}
2019-03-02T03:17:34+0100 [kotori.daq.intercom.mqtt.base      ] INFO: Starting PahoMqttAdapter. name=mqtt-hives, broker=localhost:1883, object=<kotori.daq.intercom.mqtt.paho.PahoMqttAdapter object at 0x740f3b90>
2019-03-02T03:17:34+0100 [kotori.core                        ] INFO: Enabling vendors []
2019-03-02T03:17:34+0100 [kotori.daq.intercom.mqtt.paho      ] INFO: Subscribing to topics [u'hives/#']. client=<paho.mqtt.client.Client object at 0x740f3dd0>
2019-03-02T03:17:34+0100 [kotori.daq.intercom.mqtt.paho      ] INFO: Subscribing to topic 'hives/#'

Enjoy!

2 Likes

Sorry for the inconveniences you had when starting with the DAQ backend. As mentioned above, we really should provide packages built on/for Debian Stretch. In the meanwhile, your instance should hopefully work properly - at least Kotori would start up successfully now.

However, we really can’t guarantee that the old version of Kotori will work together with the most recent Grafana version. So, please let us know about any other obstacles you might encounter during the next steps of your journey.

Dear Andreas

Thanks a lot for your help !!!

Can you tell me quickly what you do to solve this issue ?

Thanks

Georges

… wasn’t it …

Sure.

Reason

Kotori 0.15.0 (armhf) obviously lacks and doesn’t install one of its important dependencies, the pytz package from the Python Package Index.

Solution

As pip - the package installer - is also broken (sorry for that), we just download the sdist package directly from PyPI and install it manually into the Python virtualenv Kotori is shipping itself with.

Fixing the issue is just a matter of.

# Change user
su - kotori

# Download and extract Python sdist package
cd /tmp
wget https://files.pythonhosted.org/packages/af/be/6c59e30e208a5f28da85751b93ec7b97e4612268bb054d0dff396e758a90/pytz-2018.9.tar.gz
tar -xzf pytz-2018.9.tar.gz
cd pytz-2018.9/

# Install package
/opt/kotori/bin/python setup.py install

# Restart service (as root user)
systemctl restart kotori

Background

Please note that this error actually doesn’t reveal itself easily and we feel sad about the fact you ran into this, as others might also have, probably us as well ;]. The situation has already been improved with a more recent version of Kotori:

With the current version, Kotori would have yielded the corresponding exception

[...]
  File "/opt/kotori/lib/python2.7/site-packages/influxdb/client.py", line 16, in <module>
    from influxdb.line_protocol import make_lines, quote_ident, quote_literal
  File "/opt/kotori/lib/python2.7/site-packages/influxdb/line_protocol.py", line 12, in <module>
    from pytz import UTC
ImportError: No module named pytz

into its logfile at /var/log/kotori/kotori.log.

Conclusion

So, we really should get our sh… together and build fresh packages suitable to be installed on Debian Stretch, likewise for both amd64 and armhf architectures.

A post was split to a new topic: Fresh Debian packages for running Kotori on ARM

Dear @georges.gagliano,

after trying to improve things based on your experiences, we just released Kotori 0.22.6 [1] for "amd64" and "armhf". Thanks again for telling us about the issues you were having.

With kind regards,
Andreas.

[1] Kotori 0.22.6 released

Dear @Andreas
I upgrade kotori and everything is OK !
I also try a new installation to confirm that the installation procedure presented on the site works.
Thanks for all

Excellent.

Thanks already!

I have an issue when i try to install. An issue with dependencies

pi@raspberrypi:/etc/apt $ sudo apt-get install kotori influxdb grafana mosquitto mosquitto-clients
Lecture des listes de paquets… Fait
Construction de l’arbre des dépendances
Lecture des informations d’état… Fait
Certains paquets ne peuvent être installés. Ceci peut signifier
que vous avez demandé l’impossible, ou bien, si vous utilisez
la distribution unstable, que certains paquets n’ont pas encore
été créés ou ne sont pas sortis d’Incoming.
L’information suivante devrait vous aider à résoudre la situation :

Les paquets suivants contiennent des dépendances non satisfaites :
mosquitto-clients : Dépend: libmosquitto1 (= 1.5.6-0mosquitto1) mais ne sera pas installé
E: Impossible de corriger les problèmes, des paquets défectueux sont en mode « garder en l’état ».

Thanks for reporting this problem. This is probably on us as we obviously forgot to add libmosquitto-1.5.6 from upstream [1] when populating the unified package repository [2].

After experiencing different issues with the Mosquitto daemon shippped with vanilla Debian, we decided to provide packages from upstream the other day.

We will fix this problem right away.

[1] Index of /debian/pool/main/m/mosquitto/
[2] Index of /hiveeyes/foss/debian/pool/foundation/m/mosquitto/

We just added the missing files to the package repository [1]. Would you try again after updating the package index using "apt update"?

Thanks already,
Andreas.

[1] Index of /hiveeyes/foss/debian/pool/foundation/m/mosquitto/

Dear @georges.gagliano,

Did adding this package to the repository resolve the installation problems on RaspberryPi machines?

With kind regards,
Andreas.