How to fix "ImportError: cannot import name _AES" from Crypto.Cipher

How to fix "ImportError: cannot import name _AES" from Crypto.Cipher

我正在使用 pycrypto 模块加密文件。当 运行 宁 python 代码时,它运行良好:

$ python encrypt_file.py file

但是当我将 encrypt_file.py 构建为二进制文件时:

$ pyinstaller -F zip_disk.py

和运行dist

下的二进制文件
$ ./encrypt_file file

它显示以下错误:

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

为什么会这样?
如何修复 ImportError?

pycrypto 开发人员已停止进一步升级。使用替代 pycryptodome 的 pycryptodome。

pip install pycryptodome

现在它工作正常(对我有用)!