Habapp install doesn't install dependencies or create directories

Hi all, and @Spaceman_Spiff

I’m trying to install habapp on a 3.2m3 machine both manually or through openhabian-config, but it doesn’t install the dependencies:

openhabian@pi-shop3:/opt/habapp $ source bin/activate
(habapp) openhabian@pi-shop3:/opt/habapp $ habapp -config /etc/openhab/habap
Traceback (most recent call last):
  File "/opt/habapp/bin/habapp", line 5, in <module>
    from HABApp.__main__ import main
  File "/opt/habapp/lib/python3.7/site-packages/HABApp/__init__.py", line 5, in <module>
    import HABApp.__do_setup__
  File "/opt/habapp/lib/python3.7/site-packages/HABApp/__do_setup__.py", line 4, in <module>
    import pydantic  # noqa: E402
ModuleNotFoundError: No module named 'pydantic'
(habapp) openhabian@pi-shop3:/opt/habapp $ deactivate

I’ve gone through a series of removing the directory, deinstalling from openhabian-config, rebooting, etc but can’t get it to do what it is supposed to do. What am I missing?

That is very strange. What happens if you do pip install pydantic after the activate

Hi Sebastian - I should have included this info.

If I keep adding the missing dependencies one-by-one and re-running habapp each time, I eventually get to ‘paho’ which doesn’t install successfully. At this point I return to wanting a ‘clean’ installation and try to scrub the install.

Note - this is not on my main machine where habapp is running great.

Is there any error message when you try a clean install or does it fail silently?
The versions are properly pinned, so I am unsure why this would fail.

No error messages that I can see. I only sort of understand venv’s so forgive me if I’ve missed something here:

openhabian@pi-shop3:~ $ sudo systemctl stop habapp.service
openhabian@pi-shop3:~ $ sudo rm -rf /opt/habapp
openhabian@pi-shop3:~ $  cd /opt
openhabian@pi-shop3:/opt $ python3 -m venv habapp
openhabian@pi-shop3:/opt $ cd habapp
openhabian@pi-shop3:/opt/habapp $ source bin/activate
(habapp) openhabian@pi-shop3:/opt/habapp $ python3 -m pip install --upgrade pip
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pip
  Using cached https://files.pythonhosted.org/packages/a4/6d/6463d49a933f547439d6b5b98b46af8742cc03ae83543e4d7688c2420f8b/pip-21.3.1-py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-21.3.1
(habapp) openhabian@pi-shop3:/opt/habapp $ python3 -m pip install habapp
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting habapp
  Using cached https://www.piwheels.org/simple/habapp/HABApp-0.31.0-py3-none-any.whl (148 kB)
Installing collected packages: habapp
Successfully installed habapp-0.31.0
(habapp) openhabian@pi-shop3:/opt/habapp $ habapp --config /etc/openhab
Traceback (most recent call last):
  File "/opt/habapp/bin/habapp", line 5, in <module>
    from HABApp.__main__ import main
  File "/opt/habapp/lib/python3.7/site-packages/HABApp/__init__.py", line 5, in <module>
    import HABApp.__do_setup__
  File "/opt/habapp/lib/python3.7/site-packages/HABApp/__do_setup__.py", line 4, in <module>
    import pydantic  # noqa: E402
ModuleNotFoundError: No module named 'pydantic'
(habapp) openhabian@pi-shop3:/opt/habapp $

Could you remove the venv folder (/opt/habapp) and try a fresh install and show the error message?
I just tried a fresh installed (on windows) and it worked fine.

I did that in line 2 of those commands above…
I suspect it is something with my environment, not the code, but not sure how to debug…
trying on a different pi shortly

On a non-openhabian installation, it tries to install everything properly, but fails. I suspect this is because it is not an openhabian install.

I’m not sure what I need to remove to make it install like this:

(habapp) pi@pi-wireguard:/opt/habapp $ python3 -m pip install habapp
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting habapp
  Downloading https://files.pythonhosted.org/packages/cf/70/2f72081a2f2301bda6d443d4580ab47eb2b01f5192dfbc39e0a27890ccef/HABApp-0.31.0-py3-none-any.whl (150kB)
    100% |████████████████████████████████| 153kB 1.5MB/s
Collecting pydantic==1.8.2 (from habapp)
  Downloading https://files.pythonhosted.org/packages/ff/74/54e030641601112309f6d2af620774e9080f99c7a15742fc6a0b170c4076/pydantic-1.8.2-py3-none-any.whl (126kB)
    100% |████████████████████████████████| 133kB 2.9MB/s
Collecting paho-mqtt==1.5.1 (from habapp)
  Downloading https://www.piwheels.org/simple/paho-mqtt/paho_mqtt-1.5.1-py3-none-any.whl (74kB)
    100% |████████████████████████████████| 81kB 426kB/s
Collecting pendulum==2.1.2 (from habapp)
  Downloading https://files.pythonhosted.org/packages/db/15/6e89ae7cde7907118769ed3d2481566d05b5fd362724025198bb95faf599/pendulum-2.1.2.tar.gz (81kB)
    100% |████████████████████████████████| 81kB 3.4MB/s
  Installing build dependencies ... done
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.7/tokenize.py", line 447, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-p12ttpdx/pendulum/setup.py'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-p12ttpdx/pendulum/
(habapp) pi@pi-wireguard:/opt/habapp $

sorry - I missed it!

Have you updated pip before installing? I don’t see it in this window.
A new update of pip is required to make the installation of pendulum work.

Yes, in both examples (failed and working) pip is upgraded to 21.3.1

Just figured it out… needed to sudo it. Duh…

although it still dies at pendulum…

(habapp) openhabian@pi-shop3:/opt/habapp $ sudo python3 -m pip install habapp
[sudo] password for openhabian:
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting habapp
  Using cached https://files.pythonhosted.org/packages/cf/70/2f72081a2f2301bda6d443d4580ab47eb2b01f5192dfbc39e0a27890ccef/HABApp-0.31.0-py3-none-any.whl
Collecting pydantic==1.8.2 (from habapp)
  Using cached https://files.pythonhosted.org/packages/ff/74/54e030641601112309f6d2af620774e9080f99c7a15742fc6a0b170c4076/pydantic-1.8.2-py3-none-any.whl
Collecting paho-mqtt==1.5.1 (from habapp)
  Using cached https://www.piwheels.org/simple/paho-mqtt/paho_mqtt-1.5.1-py3-none-any.whl
Collecting watchdog==2.1.2 (from habapp)
  Using cached https://files.pythonhosted.org/packages/ad/9e/df37da9de16e02d8a4230dcd09d4bf7ced6cd97e1f421cbade133a011e3f/watchdog-2.1.2.tar.gz
Collecting aiohttp==3.7.4 (from habapp)
  Using cached https://www.piwheels.org/simple/aiohttp/aiohttp-3.7.4-cp37-cp37m-linux_armv7l.whl
Collecting pendulum==2.1.2 (from habapp)
  Using cached https://files.pythonhosted.org/packages/db/15/6e89ae7cde7907118769ed3d2481566d05b5fd362724025198bb95faf599/pendulum-2.1.2.tar.gz
  Installing build dependencies ... done
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.7/tokenize.py", line 447, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-lscf1s_f/pendulum/setup.py'

Hm - can you try installing pendulum==2.1.1.
Maybe the older version will work as a workaround.

Hi there, same problem over here. I’ve run sudo python3 -m pip install pendulum==2.1.1 which completed successfully, but sudo python3 -m pip install habapp is still failing.

Any suggestions?

First, ensure that pip is on the latest version

sudo python3 -m pip install pip --upgrade

Could you then try

sudo python3 -m pip install pendulum==2.1.1

and then

sudo python3 -m pip install pendulum --upgrade

thanks, it seems this problem is fixed. At least running
sudo python3 -m pip install habapp
now states Successfully installed habapp-0.31.1.

However, habapp still does not start.
sudo systemctl status habapp returns

   Active: failed (Result: exit-code) since Mon 2021-11-01 08:51:43 CET; 2s ago
     Docs: https://habapp.readthedocs.io
  Process: 2302 ExecStart=/opt/habapp/bin/habapp -c /etc/openhab/habapp (code=exited, status=1/FAILURE)
 Main PID: 2302 (code=exited, status=1/FAILURE)

Nov 01 08:51:43 oh2021 habapp[2302]: Traceback (most recent call last):
Nov 01 08:51:43 oh2021 habapp[2302]:   File "/opt/habapp/bin/habapp", line 5, in <module>
Nov 01 08:51:43 oh2021 habapp[2302]:     from HABApp.__main__ import main
Nov 01 08:51:43 oh2021 habapp[2302]:   File "/opt/habapp/lib/python3.7/site-packages/HABApp/__init__.py", line 5, in <module>
Nov 01 08:51:43 oh2021 habapp[2302]:     import HABApp.__do_setup__
Nov 01 08:51:43 oh2021 habapp[2302]:   File "/opt/habapp/lib/python3.7/site-packages/HABApp/__do_setup__.py", line 4, in <module>
Nov 01 08:51:43 oh2021 habapp[2302]:     import pydantic  # noqa: E402
Nov 01 08:51:43 oh2021 habapp[2302]: ModuleNotFoundError: No module named 'pydantic'
Nov 01 08:51:43 oh2021 systemd[1]: habapp.service: Main process exited, code=exited, status=1/FAILURE
Nov 01 08:51:43 oh2021 systemd[1]: habapp.service: Failed with result 'exit-code'.

Hm - it seems that pip thinks all HABApp dependencies are successfully installed when they are not.
Could you try install required packages by hand? Then it should start properly.

I was able to do this following the error messages when executing from the command line, with the exception that when it complains about ‘paho’ you need to install ‘paho-mqtt’. I did not specify version numbers and will test shortly, and use your list if it is not running properly.

manually reinstalling dependencies did not help.

However, I figured out that running
habapp --config PATH_TO_CONFIGURATION_FOLDER
worked, so I checked for differences … and the command above resolved to /usr/local/bin/habapp instead of /opt/habapp/bin/habapp which was called in by habapp.service.

So after changing habapp.service to use /usr/local/bin/habapp I can finally explore habapp. Thanks!

Hi,

I have the same issue with “pedantic” error. I have installed habapp using openhabian-config option. I am running latest openhabian 3.1. I installed all dependencies by hand, but it didn’t help.

penhabian@openhabian:~ $ ./habapp -c /etc/openhab/habapp/
-bash: ./habapp: No such file or directory
openhabian@openhabian:~ $ /opt/habapp/bin/habapp -c /etc/openhab/habapp/
Traceback (most recent call last):
  File "/opt/habapp/bin/habapp", line 5, in <module>
    from HABApp.__main__ import main
  File "/opt/habapp/lib/python3.7/site-packages/HABApp/__init__.py", line 5, in <module>
    import HABApp.__do_setup__
  File "/opt/habapp/lib/python3.7/site-packages/HABApp/__do_setup__.py", line 4, in <module>
    import pydantic  # noqa: E402
ModuleNotFoundError: No module named 'pydantic'

Any help will be great.
Thanks!

Can you install pendulum by hand?

Then you can install the required packages manually: