问题描述:今天在使用Crypto.Random.random的时候出现错误,具体错误原因如下:
- >>> from Crypto.Random import random
- Traceback (most recent call last):
- File "
" , line 1, in <module> - File "C:\Users\一\AppData\Local\Programs\Python\Python37\lib\site-packages\Crypto\Random\__init__.py", line 28, in <module>
- from Crypto.Random import OSRNG
- File "C:\Users\一\AppData\Local\Programs\Python\Python37\lib\site-packages\Crypto\Random\OSRNG\__init__.py", line 34, in <module>
- from Crypto.Random.OSRNG.nt import new
- File "C:\Users\一\AppData\Local\Programs\Python\Python37\lib\site-packages\Crypto\Random\OSRNG\nt.py", line 28, in <module>
- import winrandom
- ModuleNotFoundError: No module named 'winrandom'
根据查询方法,修改import winrandom为from Crypto.Random.OSRNG import winrandom (Crypto/Random/OSRNG/nt.py)
pip3 install Crypto
运行仍然报错无法解决问题,最终解决办法为:
安装的是pycrypto这个第三方库在使用这个函数的时候会报上面的错误。
想要解决winrandom这个错误可以安装pycryptodome这个第三方库,他的使用方法和pycrypto一样
pip install pycryptodome