home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.21k stars 31.16k forks source link

ImportError: cannot import name 'cygrpc' from 'grpc._cython' (beta) #131942

Closed ZephireNZ closed 3 days ago

ZephireNZ commented 5 days ago

The problem

Multiple integrations are unable to setup in the latest beta:

Looks like they're all trying to import cygrpc which is missing.

What version of Home Assistant Core has the issue?

core-2024.12.0b2

What was the last working version of Home Assistant Core?

core-2024.11.3 (but may have also worked on earlier beta builds)

What type of installation are you running?

Home Assistant Container

Integration causing the issue

google_assistant_sdk

Link to integration documentation on our website

https://rc.home-assistant.io/integrations/google_assistant_sdk

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Setup failed for 'google_assistant_sdk': Unable to import component: gRPC is not installed from please install the grpcio package to use the gRPC transport.

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/google/auth/transport/grpc.py", line 28, in <module>
    import grpc  # type: ignore
    ^^^^^^^^^^^
  File "/config/deps/grpc/__init__.py", line 22, in <module>
    from grpc import _compression
  File "/config/deps/grpc/_compression.py", line 20, in <module>
    from grpc._cython import cygrpc
ImportError: cannot import name 'cygrpc' from 'grpc._cython' (/config/deps/grpc/_cython/__init__.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1014, in async_get_component
    comp = await self.hass.async_add_import_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self._get_component, True
        ^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1074, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1022, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/google_assistant_sdk/__init__.py", line 8, in <module>
    from gassist_text import TextAssistant
  File "/usr/local/lib/python3.13/site-packages/gassist_text/__init__.py", line 2, in <module>
    from .textinput import TextAssistant
  File "/usr/local/lib/python3.13/site-packages/gassist_text/textinput.py", line 26, in <module>
    import google.auth.transport.grpc
  File "/usr/local/lib/python3.13/site-packages/google/auth/transport/grpc.py", line 30, in <module>
    raise ImportError(
        "gRPC is not installed from please install the grpcio package to use the gRPC transport."
    ) from caught_exc
ImportError: gRPC is not installed from please install the grpcio package to use the gRPC transport.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/google/auth/transport/grpc.py", line 28, in <module>
    import grpc  # type: ignore
    ^^^^^^^^^^^
  File "/config/deps/grpc/__init__.py", line 22, in <module>
    from grpc import _compression
  File "/config/deps/grpc/_compression.py", line 20, in <module>
    from grpc._cython import cygrpc
ImportError: cannot import name 'cygrpc' from 'grpc._cython' (/config/deps/grpc/_cython/__init__.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 334, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1034, in async_get_component
    self._component_future.result()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1026, in async_get_component
    comp = self._get_component()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1074, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1022, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/google_assistant_sdk/__init__.py", line 8, in <module>
    from gassist_text import TextAssistant
  File "/usr/local/lib/python3.13/site-packages/gassist_text/__init__.py", line 2, in <module>
    from .textinput import TextAssistant
  File "/usr/local/lib/python3.13/site-packages/gassist_text/textinput.py", line 26, in <module>
    import google.auth.transport.grpc
  File "/usr/local/lib/python3.13/site-packages/google/auth/transport/grpc.py", line 30, in <module>
    raise ImportError(
        "gRPC is not installed from please install the grpcio package to use the gRPC transport."
    ) from caught_exc
ImportError: gRPC is not installed from please install the grpcio package to use the gRPC transport.

Additional information

No response

home-assistant[bot] commented 5 days ago

Hey there @tronikos, mind taking a look at this issue as it has been labeled with an integration (google_assistant_sdk) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `google_assistant_sdk` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign google_assistant_sdk` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


google_assistant_sdk documentation google_assistant_sdk source (message by IssueLinks)

bdraco commented 4 days ago

Which architecture are you using?

ZephireNZ commented 3 days ago

x86 64-bit running in a container

bdraco commented 3 days ago

Where is /config/deps coming from?

ZephireNZ commented 3 days ago

From what I can tell, it looks to be the dependencies for HACS components. Clearing that off and having it re-populate seems to have resolved things 🤔

The grpc version in there before was 1.67.1 versus 1.66.2 after rebuilding from scratch. So potentially it was causing a conflict with the one that was being used by HA directly.

I'll close this off in that case, as it seems to be caused google_home custom component on upgrade.