Linux和Windows下:Python Crypto模块安装方式区别
一、Linux环境下:
from Crypto.Signature import PKCS1_v1_5
如果导包报错:
ImportError: No module named 'Crypto.Signature'
ImportError: No module named 'Crypto'
解决方法:
1、pip install crypto
2、安装成功后,将crypto名称修改为:Crypto
3、 pip3 install pycryptodome
快速方式:pip3 install -i
https://pypi.douban.com/simple pycryptodome
PyCrypto 已死,请替换为 PyCryptodome
pip3 install 模块 –upgrade –target=”指定的目录”
第三步是在linux下执行:
pip3 install pycryptodome 或者
快速方式:pip3 install -i
https://pypi.douban.com/simple pycryptodome
4、在linux环境下,输入python3
>>>from Crypto.Signature import PKCS1_v1_5
如果没有报错,说明安装生效,此导包报错已解决
二、Windows环境下:
步骤一:
将此whl文件下载成功后,放置于目录:D:\python\python3.6.2\Scripts下
步骤二:
cmd命令进入到:D:\python\python3.6.2\Scripts目录下
输入命令:pip install
pycrypto-2.6.1-cp36-cp36m-win_amd64.whl
如果出现:Successfully installed pycrypto-2.6.1 说明安装成功
步骤三:
将site-packages包下的crypto修改为:Crypto
步骤四:
如果运行时报错: ModuleNotFoundError: No module named ‘winrandom’
在目录下:D:\python\python3.6.2\Lib\site-packages\Crypto\Random\OSRNG修改nt.py文件,
将import winrandom 修改为:from . import winrandom即可