不知道为什么,非要把 pycrypto 安装搞得这么复杂……
pycrypto, 主要用来加解密
python安装pycrypto时报cl.exe错误返回状态2
一、安装 vs tool
建议C盘可用空间不低于20G,安装的时候选择默认路径,勾选自己需要安装的 文件
安装完成后
在
Program Files (x86)\Microsoft Visual Studio\20XX\Community\VC\Tools\MSVC\14.xxxxx\include\
20XX 这个是根据安装的版本不一样自己找,有2017、2019等,可能后续会有2021
14.xxxxx 这个是根据安装的版本不一样自己找,14表示的是 vc 14
找到 stdint.h 文件,
拷贝到
Program Files (x86)\Windows Kits\10\Include\10.0.xxxx.xx\ucrt\
10.0.xxxx.xx 这个是根据安装的版本不一样自己找
然后在该目录找到 inttypes.h 这个文件,一般情况下是不能在当前目录修改,复制到桌面,
将
#include <stdint.h>
修改为
#include "stdint.h"
该 双引号 为 英文格式
把修改后的文件移入刚才的目录,一般是需要管理员权限的,确认就可以
二、 安装 wheel
如果不安装 wheel ,会出现以下的警告,后面可能会影响其他的操作,
Using legacy 'setup.py install' for pycrypto, since package 'wheel' is not installed
操作
pip install wheel
三、安装 pycrypto
pip install pycrypto
四、引用 pycrypto 的时候出现
ModuleNotFoundError: No module named 'winrandom'
修改python安装目录下的 python\Lib\site-packages\Crypto\Random\OSRNG/nt.py 文件中以下代码:
注释
import winrandom
新加入
from Crypto.Random.OSRNG import winrandom
暂时没有解决………………