• python3安装Crypto过程


          公司app登录接口在传参时,有个加密字段“——key”。在使用python做接口测试时,调研可以通过Crypto包进行加密处理,而Crypto包是第三方包,需要进行安装。

          1.使用python3 -m pip install Crypto进行安装;

    结果,安装失败,报错如下:

    Could not fetch URL https://pypi.org/simple/crypto/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/crypto/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1122)'))) - skipping
    ERROR: Could not find a version that satisfies the requirement Crypto (from versions: none)
    ERROR: No matching distribution found for Crypto
    Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1122)'))) - skipping

    在网上搜索解决方法后,修改了安装命令。

           2.使用命令python3 -m pip  --trusted-host pypi.org install Crypto进行安装;

    结果,仍然安装失败,报错如下:

    ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/fc/bb/0b812dc02e6357606228edfbf5808f5ca0a675a84273578c3a199e841cd8/crypto-1.4.1-py2.py3-none-any.whl (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1122)')))

    继续寻找解决方法,修改了安装源,指定为豆瓣的镜像源。

          3.python3 -m pip install Crypto -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

    结果,安装成功。如下:

    Installing collected packages: shellescape, pyyaml, Naked, Crypto
    Successfully installed Crypto-1.4.1 Naked-0.1.31 pyyaml-5.4.1 shellescape-3.8.1

          到了这一步,Crypto算是安装成功了,但是在使用from Crypto.PublicKey import RSA导入时,提示并没有Crypto库。果然不会这么顺利的,又在网上查找解决方法。

    在进到python3安装路径后,进到site-packages目录,查看包名是小写的(crypto,crypto-1.4.1.dist-info),于是将首字母修改为大写。

          当再次导入包时from Crypto.PublicKey import RSA,又提示没有PublicKey,没辙,又在网上搜索解决办法,找到个答案说需要安装pycryptodome。还能怎么办,继续安装呗!

          4.python3 -m pip install pycryptodome -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

    至此,终于完成安装了。

          记此,避免后续继续踩坑。

        

  • 相关阅读:
    大学的最后时光---我的毕设日记(二)
    大学的最后时光---我的毕设日记(一)
    记公司同事的一次集体活动
    ssh框架基本原理
    plsql基本操作记录
    eclipse快捷键。
    面向对象的特性:封装继承多态
    设置label中的对齐方式
    pixmap和label设置图片自适应大小
    类的继承
  • 原文地址:https://www.cnblogs.com/python-kp/p/14955087.html
Copyright © 2020-2023  润新知