I'm using the pycrypto
module to encrypt files. When running the python code, it works well:
$ python encrypt_file.py file
but when I build encrypt_file.py
to a binary:
$ pyinstaller -F zip_disk.py
and run the binary under dist
$ ./encrypt_file file
it shows the following error:
File "<string>", line 24, in <module>
File "/usr/local/lib/python2.7/dist-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "/home/xxxx/zip_disk/build/zip_disk/out00-PYZ.pyz/Crypto.Cipher.AES", line 50, in <module>
ImportError: cannot import name _AES
Why does this happen?
How to fix ImportError
?
from Crypto.Cipher import AES
pycrypto
from source and via pip
, both result in the the same ImportError
.The pycrypto developers have stopped futher upgrades. Use instead pycryptodome which replaces pycrypto.
pip install pycryptodome
Now it works fine (did for me)!