2023.4.27更新:
更好的做法是安装pycryptodome
参考https://blog.csdn.net/qq_36793268/article/details/119155633
分割线-----------------
首先要注意,虽然这个库在import的时候用的名字是Crypto,比如:
import Crypto.Hash
但是在pip安装时的名字却是pycrypto
因此需要执行的安装命令是
pip install pycrypto
如果在安装的时候报错了,出现如:
error: subprocess-exited-with-error
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(31): error C2061: 语法错误: 标识符“intmax_t”
note: This error originates from a subprocess, and is likely not a problem with pip.
之类的错误信息,可以参考https://blog.csdn.net/weixin_45485719/article/details/107720007
的解决方法
然后如果pip成功安装后,import依然找不到模块,那么原因很有可能出在我在开头所说的:import和pip install是名字不一致导致的.这种情况下按顺序执行以下三条命令:
pip uninstall Crypto
pip uninstall pycrypto
pip install pycrypto
即可解决