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

Crypto package not found #497

Closed
mail4reset opened this issue Apr 27, 2024 · 3 comments
Closed

Crypto package not found #497

mail4reset opened this issue Apr 27, 2024 · 3 comments
Labels
bug Something isn't working Critical The bug is disruptive and requires immediate fix waiting validation Waiting for user's test/validation

Comments

@mail4reset
Copy link

After upgrading from v1.2.13 (meross_iot==0.4.6.2) to v.1.3.0 (meross_iot==0.4.7.0) the integration stops working with the error detailed in the log. After googling for a while I found the Crypto package seems to be deprecated. I checked in my venv and found:

(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $ pip list | grep crypto
cryptography                 42.0.5
pycryptodomex                3.20.0

So I managed to bypass this problem by changing the line 4 of the file /srv/homeassistant/lib/python3.12/site-packages/meross_iot/controller/mixins/encryption.py from from Crypto.Cipher import AES to from Cryptodome.Cipher import AES. Now the integration is working fine.

Your environment
HomeAssistant version: Core 2024.4.3 - Frontend 20240404.2
Hardware environment: Raspberry Pi 4

Logs taken when the issue happened

2024-04-27 09:39:58.969 ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration 'meross_cloud': Unable to import component: No module named 'Crypto'
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/loader.py", line 979, in async_get_component
    comp = await self.hass.async_add_import_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/loader.py", line 1037, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, 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 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/meross_cloud/__init__.py", line 17, in <module>
    from meross_iot.manager import MerossManager
  File "/srv/homeassistant/lib/python3.12/site-packages/meross_iot/manager.py", line 21, in <module>
    from meross_iot.device_factory import (
  File "/srv/homeassistant/lib/python3.12/site-packages/meross_iot/device_factory.py", line 10, in <module>
    from meross_iot.controller.mixins.encryption import EncryptionSuiteMixin
  File "/srv/homeassistant/lib/python3.12/site-packages/meross_iot/controller/mixins/encryption.py", line 4, in <module>
    from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/setup.py", line 316, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/loader.py", line 997, in async_get_component
    self._component_future.result()
  File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/loader.py", line 989, in async_get_component
    comp = self._get_component()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/loader.py", line 1037, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, 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 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/meross_cloud/__init__.py", line 17, in <module>
    from meross_iot.manager import MerossManager
  File "/srv/homeassistant/lib/python3.12/site-packages/meross_iot/manager.py", line 21, in <module>
    from meross_iot.device_factory import (
  File "/srv/homeassistant/lib/python3.12/site-packages/meross_iot/device_factory.py", line 10, in <module>
    from meross_iot.controller.mixins.encryption import EncryptionSuiteMixin
  File "/srv/homeassistant/lib/python3.12/site-packages/meross_iot/controller/mixins/encryption.py", line 4, in <module>
    from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto'
@albertogeniola
Copy link
Owner

Hi @mail4reset ,
good catch. This is an error on the low MerossIot library, which missed the correct dependency import within setup.py. I'll check on that and report back when a newer beta version is ready for you to test.

@albertogeniola albertogeniola added bug Something isn't working Critical The bug is disruptive and requires immediate fix labels Apr 27, 2024
@albertogeniola albertogeniola added this to the Version v1.3.1 milestone Apr 27, 2024
@albertogeniola albertogeniola pinned this issue Apr 27, 2024
@albertogeniola
Copy link
Owner

Hi @mail4reset ,

v1.3.1 should fix the issue. Can you please test it and report if working as expected now?

@albertogeniola albertogeniola added the waiting validation Waiting for user's test/validation label Apr 28, 2024
@mail4reset
Copy link
Author

Hi Alberto,
v1.3.1 solved the issue.
Thank you very much for your quick answer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Critical The bug is disruptive and requires immediate fix waiting validation Waiting for user's test/validation
Projects
None yet
Development

No branches or pull requests

2 participants