Xiaomi Gateway - pyCrypto Issue

Hi everyone

I’ve spent hours trying to fix this issue but I can’t seem to fix it at all:

2017-10-30 21:02:42 ERROR (MainThread) [homeassistant.setup] Error during setup of component xiaomi_aqara
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/setup.py", line 194, in _async_setup_component
    component.setup, hass, processed_config)
  File "/usr/lib/python3.5/asyncio/futures.py", line 379, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 297, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 292, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/xiaomi_aqara.py", line 93, in setup
    from PyXiaomiGateway import PyXiaomiGateway
  File "/home/userr/.homeassistant/deps/lib/python3.5/site-packages/PyXiaomiGateway/__init__.py", line 9, in <module>
    from Crypto.Cipher import AES
  File "/home/userr/.homeassistant/deps/lib/python3.5/site-packages/Crypto/Cipher/__init__.py", line 3, in <module>
    from Crypto.Cipher._mode_ecb import _create_ecb_cipher
  File "/home/userr/.homeassistant/deps/lib/python3.5/site-packages/Crypto/Cipher/_mode_ecb.py", line 29, in <module>
    from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
  File "/home/userr/.homeassistant/deps/lib/python3.5/site-packages/Crypto/Util/_raw_api.py", line 32, in <module>
    from Crypto.Util.py3compat import byte_string
ImportError: cannot import name 'byte_string'

I’m running v0.56.2. I’ve tried uninstalling/reinstalling pycrypto a number of times without any success.

Any ideas?

Thank you!

Are you using special characters in your gateway name? Can you share your config?

PyCrypto will not be required for Xiaomi gw from the next release of HA.
So you can install the latest dev version or wait until Saturday.

But it seems that you use pycryptodome and not pycrypto.
Try to uninstall pycryptodome and install pycrypto

1 Like

Thanks Daniel,

userr@automate:~/Desktop$ sudo -H pip3 uninstall pycryptodome
Cannot uninstall requirement pycryptodome, not installed
userr@automate:~/Desktop$ sudo -H pip3 install pycrypto
Requirement already satisfied: pycrypto in /usr/local/lib/python3.5/dist-packages

Have tried this multiple times. No success :frowning:

If I install the dev version, can I get back onto the stable branch easily? How? :slight_smile:

Thanks

Pycryptodome is installed in
/home/userr/.homeassistant/deps/lib/python3.5/site-packages/Crypto

I think it is safe to delete that folder.

But you might have another HA component that requires Pycryptodome?
Pycryptodome and Pycrypto can not be installed together. So the two components might not be compatible.

1 Like

Thought I would try again today.

I deleted the folder at
/home/userr/.homeassistant/deps/lib/python3.5/site-packages/Crypto

Then restarted HASS and it worked! Thank you so much!