问题

应用Crypto库时呈现No module named 'Crypto'

Crypto的依赖库

pip install pycryptodomepip install cryptopip install pycrypto

我的python版本是3.7,应用pip install pycrypto命令时报错:

C:\Users\MI\AppData\Local\Programs\Python\Python37>Pip3.7 install pycryptoCollecting pycrypto  Using cached pycrypto-2.6.1.tar.gz (446 kB)Using legacy 'setup.py install' for pycrypto, since package 'wheel' is not installed.Installing collected packages: pycrypto    Running setup.py install for pycrypto ... error    ERROR: Command errored out with exit status 1:     command: 'c:\users\mi\appdata\local\programs\python\python37\python37.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\MI\\AppData\\Local\\Temp\\pip-install-iwoi68sx\\pycrypto_11418f0350244305b0226b38fc392f84\\setup.py'"'"'; __file__='"'"'C:\\Users\\MI\\AppData\\Local\\Temp\\pip-install-iwoi68sx\\pycrypto_11418f0350244305b0226b38fc392f84\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\MI\AppData\Local\Temp\pip-record-8g35bcmi\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\mi\appdata\local\programs\python\python37\Include\pycrypto'

报错起因

pycrypto、pycrytodome和crypto是一个货色,crypto在python下面的名字是pycrypto,它是一个第三方库,然而曾经进行更新三年了。

解决办法

  1. 应用pip命令装置以下依赖库,忽视报错:

    pip install pycryptodomepip install cryptopip install pycrypto
  2. 关上\Python\Python37\Lib\site-packages这个门路,找到crypto这个文件夹。
  3. crypto这个文件夹重命名为Crypto
  4. 从新运行程序即可发现No module named 'Crypto'报错隐没。

参考

No module named 'Crypto' 解决方案