-
Notifications
You must be signed in to change notification settings - Fork 58
-
I'm not sure if I'm doing something wrong here. My py script has "from Crypto.Cipher import AES" which fails.
The error in the log is:
from Crypto.Cipher import AES
^
AttributeError: module 'Crypto.Cipher' has no attribute 'AES'
I created a requirements.txt in the the pyscript folder and in it:
pycryptodome==3.2
I look at the source files (https://pypi.org/project/pycryptodome/#files) and I see that it should include the AES attribute inside Crypto.Cipher. The same code works fine on my computer, so I know the import should work.
Other imports work fine. "Allow All Imports" is selected.
Any assistance will be greatly appreciated...
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 4 comments 3 replies
-
try this structure:
image
then in pyscript/config.yaml
allow_all_imports: true apps: air_raid_alarm:
Beta Was this translation helpful? Give feedback.
All reactions
-
I get the exact same error.
from Crypto.Cipher import AES
^
AttributeError: module 'Crypto.Cipher' has no attribute ['AES']
I'm attaching the code and the folder.
Beta Was this translation helpful? Give feedback.
All reactions
-
my second guess is that HA Core has this prerequisite of the exact version 3.6.6 https://github.com/search?q=repo%3Ahome-assistant%2Fcore%20pycryptodome&type=code and you are trying to expect the latest 3.20.0, which can be achieved only by adding pycryptodome==3.20.0
in your requirements.txt, but this can lead to exceptions in HA Core that relies on the lower verison.
Beta Was this translation helpful? Give feedback.
All reactions
-
pycryptodome version 3.6.6 should also work, and it also has the AES attribute (I looked at the source here: https://pypi.org/project/pycryptodome/3.6.6/#files), I changed the requirements.txt to "pycryptodome==3.6.6" (or perhaps it's not needed at all now), but I still get the same error.
Beta Was this translation helpful? Give feedback.
All reactions
-
3.6.6 does not work for me, but with a different error
image
Beta Was this translation helpful? Give feedback.
All reactions
-
Another interesting thing, if I use "pycryptodomex" instead (I see I also don't need it in the requirements, it tells me it's included), then I also can't do "from Cryptodome.Cipher import AES" for some reason.
Beta Was this translation helpful? Give feedback.
All reactions
-
I took the entire Crypto package from GitHub (which has an attribute for AES) and renamed Crypto to Crypto2.
Then, I did a find & replace on all the files inside this package to replace the import Crypto into import Crypto2.
I placed the entire package in pyscript/modules/Crypto2 folder.
If I do from Crypto2.Cipher import AES I get a ton of errors about file is not defined. I feel like I'm close.
The package is attached.
Beta Was this translation helpful? Give feedback.