gpt4 book ai didi

python - 无模块名称加密

转载 作者:太空宇宙 更新时间:2023-11-03 21:06:01 25 4
gpt4 key购买 nike

我正在尝试在我的 python 程序中导入加密货币,但出现错误。我正在 Windows 上工作。请帮忙。

cmd

C:\Users\Raw.306498\Desktop>pip3 install --upgrade pycryptodome
Requirement already up-to-date: pycryptodome in c:\users\raw.306498\appdata\lo
cal\programs\python\python37\lib\site-packages (3.8.0)

C:\Users\Raw.306498\Desktop>python test.py
Traceback (most recent call last):
File "test.py", line 2, in <module>
from Crypto.Cipher import DES
ModuleNotFoundError: No module named 'Crypto'

C:\Users\Raw.306498\Desktop>

test.py

from Crypto.Util.asn1 import DerBitString
from binascii import hexlify, unhexlify

passw=b'21566572697461733131'
s = unhexlify(passw)
cred=str(s,'ascii')

最佳答案

文档 here 中解释了针对 Windows 用户的此问题的解决方案 它说:

The root cause is that, in the past, you most likely have installed an unrelated but similarly named package called crypto, which happens to operate under the namespace crypto

解决问题:

pip uninstall crypto
pip uninstall pycryptodome
pip install pycryptodome

更多关于原因的阐述可以在这个github issue中看到。

更新:
如果文档中引用的解决方案不起作用,您必须将包文件夹名称从 crypto 更改为 Crypto。查找包文件夹所在的位置:

  1. 通过以下命令找出您的 python 可执行文件所在的位置:where python
    输出应如下所示:
    C:\Users\_YourUserName_\AppData\Local\Programs\Python\Python37-32\python.exe
  2. 现在将 cmd 中的目录更改为包含 python 的文件夹:
    cd C:\Users\_YourUserName_\AppData\Local\Programs\Python\Python37-32\
  3. 运行这些:

    cd ..cd cd Lib\site-packages

  4. 在此目录中打开资源管理器:
    资源管理器。
  5. 在打开的资源管理器中,您可以看到一个名为:crypto的文件夹,将其重命名为Crypto。 (第二个以大写C开头)

关于python - 无模块名称加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55393742/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com