tuya-convert: ModuleNotFoundError: No module named 'Cryptodome'

When flashing a new device with

Starting smart config pairing procedure
Waiting for the device to install the intermediate firmware
Traceback (most recent call last):
  File "./smartconfig/main.py", line 15, in <module>
    from smartconfig import smartconfig
  File "/home/fred/tuya-convert/scripts/smartconfig/smartconfig.py", line 43, in <module>
    from multicast import multicast_head, encode_multicast_body
  File "/home/fred/tuya-convert/scripts/smartconfig/multicast.py", line 12, in <module>
    from Cryptodome.Cipher import AES
ModuleNotFoundError: No module named 'Cryptodome'

This is with the latest checkout (release v2.4.3) on my Raspberry Pi 4. I’ll try and fix the issue and report back.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 25

Most upvoted comments

this help

sudo rm /usr/lib/python3.11/EXTERNALLY-MANAGED

I had this same issue, which was a result of installing the prerequisites as sudo - and then running start_flash.sh without sudo.

So to reword this - manually installing the prerequisites from install_prereq.sh without sudo fixed my issue (or running start_flash.sh with sudo).

had same issue

Waiting for the device to install the intermediate firmware
Traceback (most recent call last):
  File "./smartconfig/main.py", line 15, in <module>
    from smartconfig import smartconfig
  File "/home/pi/tuya-convert/scripts/smartconfig/smartconfig.py", line 43, in <module>
    from multicast import multicast_head, encode_multicast_body
  File "/home/pi/tuya-convert/scripts/smartconfig/multicast.py", line 12, in <module>
    from Cryptodome.Cipher import AES
ModuleNotFoundError: No module named 'Cryptodome'

I have resolved my problem by 2 simple commands on pi:

sudo apt-get update
sudo apt-get install python3-pycryptodome

after that you can check if module has been installed properly: python3 -c 'from Cryptodome.Cipher import AES; print("Cryptodome works!")' The output should be: Cryptodome works!

Then started flashing again and works fine

this help

sudo rm /usr/lib/python3.11/EXTERNALLY-MANAGED

This worked for me

UPDATE: I’m getting a different error from pi@octopi:~/tuya-convert/scripts/smartconfig $ python3 main.py after running sudo pip3 install pycryptodomex and letting that install. I will try to reflash shortly because the error looks like the error is related to the AP not running. 🤞

Sorry for some minor cross-posting, but this other thread was the second most promising: https://github.com/ct-Open-Source/tuya-convert/issues/643

2nd UPDATE: I noticed I still had the following errors in smarthack-psk.log and smarthack-web.log respectively:

Traceback (most recent call last):
  File "./psk-frontend.py", line 6, in <module>
    import sslpsk
ModuleNotFoundError: No module named 'sslpsk'
Traceback (most recent call last):
  File "./fake-registration-server.py", line 9, in <module>
    import tornado.web
ModuleNotFoundError: No module named 'tornado'

Both appear to have been solved by running sudo pip3 install sslpsk and sudo pip3 install tornado respectively and letting each finish installing before continuing on. I will try to reflash again, but I wanted to update my troubleshooting as I went. BTW, I still get the error Command "git clone -q https://github.com/drbild/sslpsk.git /tmp/pip-req-build-m7e4a1si" failed with error code 1 in None when I re-run ./install_prereq.sh, but at least I’m not getting anymore ModuleNotFoundError: No module named 'sslpsk' errors in my smarthack-psk.log file

NOTE: This may be an issue with trying to run tuya-convert from a spare RPi running Octopi because I have found other threads of people having issues from this distribution - but it should theoretically be supported because Octopi is just a customized distro of Raspberry Pi OS which is itself a Debian distro, right?