No module named 'Crypto'的解决方案

Posted ShadowCK

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了No module named 'Crypto'的解决方案相关的知识,希望对你有一定的参考价值。

问题

使用Crypto库时出现No module named \'Crypto\'

Crypto的依赖库

pip install pycryptodome
pip install crypto
pip install pycrypto

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

C:\\Users\\MI\\AppData\\Local\\Programs\\Python\\Python37>Pip3.7 install pycrypto
Collecting 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 pycryptodome
    pip install crypto
    pip install pycrypto
  2. 打开\\Python\\Python37\\Lib\\site-packages这个路径,找到crypto这个文件夹。
  3. crypto这个文件夹重命名为Crypto
  4. 重新运行程序即可发现No module named \'Crypto\'报错消失。

参考

No module named \'Crypto\' 解决方案

以上是关于No module named 'Crypto'的解决方案的主要内容,如果未能解决你的问题,请参考以下文章

python27 ImportError: No module named site

python 3.x报错:No module named 'cookielib'或No module named 'urllib2'

python -ImportError: No module named site

ModuleNotFoundError: No module named 'cStringIO'

ModuleNotFoundError: No module named 'urlparse'

ImportError : No module named graphics