python3报错:ModuleNotFoundError: No module named ‘Crypto.Cipher‘

1、问题

win10 上 执行 python 脚本,然后报错了,提示 ModuleNotFoundError: No module named 'Crypto.Cipher',如下面所示:

Traceback (most recent call last):
  File "D:\study\Python\gradio\main.py", line 6, in <module>
    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 <module>
    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、然后再运行脚本时,就不会报错了。

 

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

懒羊羊夸夸~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值