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

Setup failed for icloud after update to 2022.3.X #67845

Closed
Waylikemark opened this issue Mar 8, 2022 · 12 comments
Closed

Setup failed for icloud after update to 2022.3.X #67845

Waylikemark opened this issue Mar 8, 2022 · 12 comments

Comments

@Waylikemark
Copy link

The problem

Since the update to HA 2022.3.X (i went from the latest 2022.2 to 2022.3.2) the icloud integration fails to setup. Also deleting the integration is not possible. If i restore my backup from 2022.2.X it works again but after the update te integration fails to load again.

What version of Home Assistant Core has the issue?

2022.3.3

What was the last working version of Home Assistant Core?

2022.2.X

What type of installation are you running?

Home Assistant OS

Integration causing the issue

iCloud

Link to integration documentation on our website

https://www.home-assistant.io/integrations/icloud/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.setup
Source: setup.py:162 
First occurred: 08:49:16 (1 occurrences) 
Last logged: 08:49:16

Setup failed for icloud: Unable to import component: cannot import name 'get_localzone_name' from 'tzlocal' (/usr/local/lib/python3.9/site-packages/tzlocal/__init__.py)

—————

Logger: aiohttp.server
Source: components/icloud/account.py:9 
First occurred: 08:50:58 (1 occurrences) 
Last logged: 08:50:58

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 79, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 219, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 72, in delete
    result = await hass.config_entries.async_remove(entry_id)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 858, in async_remove
    await entry.async_remove(self.hass)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 510, in async_remove
    component = integration.get_component()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 553, in get_component
    cache[self.domain] = importlib.import_module(self.pkg_path)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/icloud/__init__.py", line 13, in <module>
    from .account import IcloudAccount
  File "/usr/src/homeassistant/homeassistant/components/icloud/account.py", line 9, in <module>
    from pyicloud import PyiCloudService
  File "/usr/local/lib/python3.9/site-packages/pyicloud/__init__.py", line 3, in <module>
    from pyicloud.base import PyiCloudService
  File "/usr/local/lib/python3.9/site-packages/pyicloud/base.py", line 19, in <module>
    from pyicloud.services import (
  File "/usr/local/lib/python3.9/site-packages/pyicloud/services/__init__.py", line 2, in <module>
    from pyicloud.services.calendar import CalendarService
  File "/usr/local/lib/python3.9/site-packages/pyicloud/services/calendar.py", line 5, in <module>
    from tzlocal import get_localzone_name
ImportError: cannot import name 'get_localzone_name' from 'tzlocal' (/usr/local/lib/python3.9/site-packages/tzlocal/__init__.py)

Additional information

No response

@probot-home-assistant
Copy link

icloud documentation
icloud source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @Quentame, @nzapponi, mind taking a look at this issue as it has been labeled with an integration (icloud) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@estebanz01
Copy link

I confirm it's still happening on latest 2022.3.5 version:

Logger: homeassistant.setup
Source: setup.py:162
First occurred: 14:29:26 (1 occurrences)
Last logged: 14:29:26

Setup failed for icloud: Unable to import component: cannot import name 'get_localzone_name' from 'tzlocal' (/srv/homeassistant/lib/python3.9/site-packages/tzlocal/__init__.py)

@povlhp
Copy link

povlhp commented Apr 6, 2022

Still same issue. 2022.3.8

@Waylikemark
Copy link
Author

Even on the 2022.04 beta's the issue is still there. Sometimes after an update iCloud loads correctly but once you reboot HA the issue is back

@dexn
Copy link

dexn commented Apr 7, 2022

Screenshot_20220407-162443_Home Assistant
Screenshot_20220407-161214_Home Assistant
Same issue on 2022.04

@dexn
Copy link

dexn commented Apr 7, 2022

I found pyicloud had a breaking change in February, "Migrate from pytz #377"

@michaelblight
Copy link

Sadly still an issue with 2022.4.5 - after the initial upgrade to 2022.4.5 it was working, but then a subsequent restart of HA produced the error again.

@pointjalta
Copy link

pointjalta commented Apr 30, 2022

I am having this issue as well I think. Tried to resolve it myself and tried to make sense out of the log files. I removed the iCloud dir from the .storage dir the iCloud dir too. For some puzzling reason I just can not remove the iCloud integration. At one point I thought, obviously useless, I might help to just remove all apple linked intergrations. I sure could remove those but the iCloud integration constantly states it can't be loaded but I also can't disable it. Let alone remove it. Annoying.

I hope someone finds out what is causing this though. I clearly not capable to fix this yet. :(

error

@michaelblight
Copy link

michaelblight commented May 6, 2022

Damn! It was working fine again after multiple restarts on 2022.4.6, but after upgrading to 2022.5.1 it initially worked, but then about 4 hours later, HA mysteriously restarted (not sure how to diagnose why), and now I'm back to this error. And I can't remember the secret sauce from last time to getting it working again. This time I deleted /storage/iCloud then restarted, at which point it said "One of your integrations requires reconfiguration". Clicking on Reconfigure and re-entering the password etc got it working again.

Edit: I run on a VirtualBox VM on Ubuntu, and it appears the whole machine rebooted, so that part is presumably not linked to HA. Just suspicious that it's a few hours after the upgrade.

@michaelblight
Copy link

Not working again on 2022.6.1, despite deleting the integration before the upgrade (but fixed!).

Now I don't really know how Home Assistant installs integrations, but if I use Portainer to connect to the "homeassistant" container and enter pip show tzlocal, I get version 2, despite the "requirements.txt" for pyicloud wanting at least 4.0. Whereas if I go back to the working version (using a VM snapshot), tzlocal is on version 4.2. So it's like an upgrade to Home Assistant is installing an older version of "tzlocal".

If I manually install version 4.2, I get warnings/errors that this is incompatible with Grocy, which requires version 2 or 3. However, I can then install the iCloud integration, and Grocy doesn't seem to care.

bash-5.1# pip install tzlocal==4.2
Collecting tzlocal==4.2
  Downloading tzlocal-4.2-py3-none-any.whl (19 kB)
Requirement already satisfied: pytz-deprecation-shim in /usr/local/lib/python3.9/site-packages (from tzlocal==4.2) (0.1.0.post0)
Requirement already satisfied: tzdata in /usr/local/lib/python3.9/site-packages (from pytz-deprecation-shim->tzlocal==4.2) (2022.1)
Installing collected packages: tzlocal
  Attempting uninstall: tzlocal
    Found existing installation: tzlocal 2.1
    Uninstalling tzlocal-2.1:
      Successfully uninstalled tzlocal-2.1
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pygrocy 1.0.0 requires iso8601~=0.1.16, but you have iso8601 0.1.12 which is incompatible.
pygrocy 1.0.0 requires tzlocal<3.0,>=2.1, but you have tzlocal 4.2 which is incompatible.
Successfully installed tzlocal-4.2

Furthermore, if I go back to a snapshot after the upgrade when the integration was installed but broken, I can install 4.2, restart, and get it working again.

So in my mind, the problem is with Home Assistant not being able to cope with conflicting requirements - Grocy wants version 2-3, but iCloud wants version 4+ (sounds like the old DLL-hell of Windows). Having said that, the Grocy add-on asks for version 1.2.1 of "pygrocy", but only version 1.0 gets installed, so maybe this is why. It's all too confusing, but at least this looks like a reasonably reliable method of fixing it.

@github-actions
Copy link

github-actions bot commented Sep 2, 2022

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Sep 2, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants