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
?
- 我的导入语句是
from Crypto.Cipher import AES
- Python版本:Python2.7.6
- PyCrypto 版本为 2.6.1。我尝试从源代码和通过
pip
安装 pycrypto
,两者的结果相同 ImportError
.
- 平台:Linux Ubuntu 3.13.0-32-generic x86_64 x86_64 GNU/Linux
pycrypto 开发人员已停止进一步升级。使用替代 pycryptodome 的 pycryptodome。
pip install pycryptodome
现在它工作正常(对我有用)!
我正在使用 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
?
- 我的导入语句是
from Crypto.Cipher import AES
- Python版本:Python2.7.6
- PyCrypto 版本为 2.6.1。我尝试从源代码和通过
pip
安装pycrypto
,两者的结果相同ImportError
. - 平台:Linux Ubuntu 3.13.0-32-generic x86_64 x86_64 GNU/Linux
pycrypto 开发人员已停止进一步升级。使用替代 pycryptodome 的 pycryptodome。
pip install pycryptodome
现在它工作正常(对我有用)!