win10 上 执行 python 脚本,然后报错了,提示 ModuleNotFoundError: No module named 'Crypto.Cipher'
,如下面所示:
Traceback (most recent call last):
File "D:\study\Python\gradio\main.py", line 6, in
from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto.Cipher'
解决方案:
1、安装Crypto 模块,执行 pip install Crypto
,安装成功后,再执行命令,还是报上面的错误。
2、然后又安装命令 pip install Crypto.Cipher
,安装成功,信息如下:
(venv) D:\study\Python\gradio>pip install Crypto.Cipher
Collecting Crypto.Cipher
Downloading Crypto.Cipher-1-py3-none-any.whl (1.3 kB)
Requirement already satisfied: requests in d:\study\gradio\venv\lib\site-packages (from Crypto.Cipher) (2.31.0)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\study\gradio\venv\lib\site-packages (from requests->Crypto.Cipher) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in d:\study\gradio\venv\lib\site-packages (from requests->Crypto.Cipher) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in d:\study\gradio\venv\lib\site-packages (from requests->Crypto.Cipher) (2.0.3)
Requirement already satisfied: certifi>=2017.4.17 in d:\study\gradio\venv\lib\site-packages (from requests->Crypto.Cipher) (2023.5.7)
Installing collected packages: Crypto.Cipher
Successfully installed Crypto.Cipher-1
3、运行还是报错:
Traceback (most recent call last):
File "D:\study\Python\gradio\main.py", line 6, in
from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto.Cipher'
4、第1步: 在python3 (或者 python 虚拟环境)目录下的 /Lib/site-packages/ 目录下找到 crypto 、crypto-1.4.1.dist-info 目录,将crypto 首字母改为大写,即修改名称为 Crypto、 Crypto-1.4.1.dist-info 。(如果没有 crypto
、crypto-1.4.1.dist-info
目录,则先执行安装 pip install Crypto
。)
5、检查目录下没有 pycryptodome
模块,如果没有,则安装 pycryptodome。
pip install pycryptodome
6、然后再运行脚本时,就不会报错了。