修复在python3中ImportError: No module named 'winrandom'错误
错误提示信息如下:
Traceback (most recent call last):
File "D:\software\python35\lib\site-packages\Crypto\PublicKey\RSA.py", line 78, in <module>
from Crypto import Random
File "D:\software\python35\lib\site-packages\Crypto\Random\__init__.py", line 28, in <module>
from Crypto.Random import OSRNG
File "D:\software\python35\lib\site-packages\Crypto\Random\OSRNG\__init__.py", line 34, in <module>
from Crypto.Random.OSRNG.nt import new
File "D:\software\python35\lib\site-packages\Crypto\Random\OSRNG\nt.py", line 28, in <module>
import winrandom
ImportError: No module named 'winrandom'
解决方法:
修改python安装目录下的 lib/Crypto/Random/OSRNG/nt.py 文件中以下代码:
import winrandom
修改为:
from Crypto.Random.OSRNG import winrandom
参考:
https://github.com/dlitz/pycrypto/commit/10abfc8633bac653eda4d346fc051b2f07554dcd