Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Setup Issue #71

Open
mth211 opened this issue Aug 31, 2023 · 10 comments
Open

Initial Setup Issue #71

mth211 opened this issue Aug 31, 2023 · 10 comments

Comments

@mth211
Copy link

mth211 commented Aug 31, 2023

Having issues with initial setup. Logs report:

Logger: homeassistant.config_entries
Source: config_entries.py:865
First occurred: 12:23:31 (1 occurrences)
Last logged: 12:23:31

Error occurred loading flow for integration birdbuddy: cannot import name 'BirdBuddy' from 'birdbuddy.client' (/usr/local/lib/python3.11/site-packages/birdbuddy/client.py)

I previously had BirdBuddy running a-ok but just migrated to a dedicated pi4 and this was the only integration that didn't come back as working. Have tried uninstalling and redownloading etc but this error is persistent. I don't have a python3.11/site-packages/ directory, but digging any deep than that is outside my usual skillset

@jhansche
Copy link
Owner

So you migrated to a new system - I'm assuming you also restored a backup?

This generally means that the dependency (pybirdbuddy) did not get installed, or did not get installed for this version of Python/pip. But Home Assistant manages that for us, so there's nothing special that we're doing that would interfere with HA's ability to perform this install. The installation should happen at the time you click from "Add Integration -> Bird Buddy" (it'll show a loading dialog while it's loading the config flow).

I'm running HA 2023.8.4 and Bird Buddy integration (from HACS) v0.0.17, and not seeing any issues: HA automatically installed pybirdbuddy v0.0.16 as it should, and it's working correctly. I can see the pybirdbuddy dist is installed at the same location your error message presents (note that pybirdbuddy is the PyPI package name, but when it installs, it's in the birdbuddy package which is what the HA integration uses - this is totally normal):

# ls -l /usr/local/lib/python3.11/site-packages/birdbuddy/client.py  /usr/local/lib/python3.11/site-packages/pybirdbuddy-0.0.16.dist-info/INSTALLER 
-rw-r--r--    1 root     root         28130 Aug 29 01:03 /usr/local/lib/python3.11/site-packages/birdbuddy/client.py
-rw-r--r--    1 root     root             4 Aug 29 01:03 /usr/local/lib/python3.11/site-packages/pybirdbuddy-0.0.16.dist-info/INSTALLER

You'll need to check your HA logs from when you added the integration, to see if it reports any errors during the pip install of dependencies.

If all else fails, try removing the BB integration, remove the BB repository from HACS, restart HA, and then try readding in HACS and readd the integration.

@mth211
Copy link
Author

mth211 commented Aug 31, 2023

Thanks for taking a look. Yes, I migrated OS then restored from a backup.

Sadly in my fault finding, I'd already removed, restarted and then readded several times, all without any luck. Every time I try and readd the integration, the only log message I can find is the same as above.

Is there a separate way I can install pybirdbuddy?

@jhansche
Copy link
Owner

If you can get shell access to the container, you can install it using pip install pybirdbuddy. That's all HA would do when installing the integration.

@jhansche
Copy link
Owner

jhansche commented Sep 2, 2023

Any change @mth211? Sometimes there might be an intermittent issue, like if pypi.org is down when you tried installing, or something like that (has happened to me before).

If it's still failing, then there has to be a log indicating why it failed, somewhere. In my case I'm pretty sure it was while running from the IDE, so the logs were printed to my console. But the same logs should be in the core log file.

Have you tried using a prior version? You can select the version you want to install from HACS. From HACS find the Bird Buddy repository, then in the overflow menu select "Redownload" and you can choose the version from there. Try version 0.0.16 or older, and see if that helps.

@mth211
Copy link
Author

mth211 commented Sep 5, 2023

No luck yet, I've tried various versions and keep returning the same error.

Full core logs don't show anything else 2023-09-05 18:14:46.620 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading flow for integration birdbuddy: cannot import name 'BirdBuddy' from 'birdbuddy.client' (/usr/local/lib/python3.11/site-packages/birdbuddy/client.py) with nothing else in the logs before or after.

This is a direct Home Assistant OS install on a Pi, but I can't think how that would cause the problems.

I'll keep trying intermittently, it's certainly not a critical home automation, and hopefully it'll work again at some point

@jhansche
Copy link
Owner

jhansche commented Sep 5, 2023

I haven't used HAOS myself, but I can't imagine that it has some kind of restriction on PyPI installations - virtually every integration will require additional libraries to be installed via pip, and that is where this package would be installed from.

Since it is listing the actual path to the site-packages/birdbuddy/client.py file in the error message, that implies that maybe it did install it properly; but perhaps there's some kind of syntax error it is encountering and that error may be swallowed by the config entry code 🤷‍♂️

As I understand, you probably would not be able to get shell access on HAOS? Maybe we can try something like a Shell integration to do some debugging. Maybe something like:

shell_command:
  bbdebug: ls -l /usr/local/lib/python3.11/site-packages/*birdbuddy

and a script to call it and log the results:

sequence:
  - service: shell_command.bbdebug
    response_variable: bbresult
  - service: logbook.log
    data:
      name: BirdBuddy
      message: "stdout = {{ bbresult['stdout'] }}; stderr = {{ bbresult['stderr'] }}; code = {{ bbresult['returncode'] }}"

Reload the config and then run the script, and look for the output in <ha-url>/logbook. Other commands you can try might be:

  bbdebug: "pip list | grep birdbuddy"

or even try to install it manually:

  bbdebug: pip install pybirdbuddy==0.0.16

migrated to a dedicated pi4

What did you migrate from? Was it also a pi server? Was it also HAOS?

@mth211
Copy link
Author

mth211 commented Sep 6, 2023

Logbook response for 1st is
BirdBuddy stdout = total 8 -rw-r--r-- 1 root root 0 Aug 30 22:00 __init__.py drwxr-xr-x 2 root root 4096 Aug 30 22:06 __pycache__ -rw-r--r-- 1 root root 0 Aug 30 22:00 birds.py -rw-r--r-- 1 root root 0 Aug 30 22:00 client.py -rw-r--r-- 1 root root 0 Aug 30 22:00 const.py -rw-r--r-- 1 root root 0 Aug 30 22:00 exceptions.py -rw-r--r-- 1 root root 0 Aug 30 22:00 feed.py -rw-r--r-- 1 root root 0 Aug 30 22:00 feeder.py -rw-r--r-- 1 root root 0 Aug 30 22:00 media.py drwxr-xr-x 3 root root 4096 Aug 30 22:00 queries -rw-r--r-- 1 root root 0 Aug 30 22:00 sightings.py -rw-r--r-- 1 root root 0 Aug 30 22:00 user.py; stderr = ; code = 0 triggered by service Scripts: 1693997906891

It looks like manually triggering the install seems to have resolved the problem, and I can now add the integration again. I sadly didn't check if it was still non functional before I ran the manual install, so can't be sure if it had resolved itself, or if the manual install was the trick.

I'll keep an eye on it

Thanks for the help in getting it resolved for me

@jhansche
Copy link
Owner

jhansche commented Sep 6, 2023

OK, so that first response is showing that the library was installed in the correct location. So this doesn't really make sense why it would report that it cannot be imported.

It seems that the backup you restored from was apparently missing something? How did you perform the backup that you restored from - was it manual or automated/scheduled?

But if manually installing it did the trick, that's good to know. Unfortunately I don't really have any ideas about what could have caused it. But if I get some spare time I'll see if I can recreate the scenario:

  • Install integration
  • Backup installation
  • Wipe the HA installation from scratch
  • Restore from backup

@mth211
Copy link
Author

mth211 commented Sep 6, 2023

It's odd! I do wonder if something external was causing the issue and it just happened that it got resolved between my last check and it working after manual install

Restored from a manual backup that was made just prior to decommissioning previous HA instance, via Google Backups. Your order of events is in line with how I changed OS

@nota3k
Copy link

nota3k commented Oct 15, 2024

I'm having this same issue after restoring a backup from VM to docker container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants