zoukankan      html  css  js  c++  java
  • 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

    至此,终于完成安装了。

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

        

  • 相关阅读:
    HDU 2544 最短路
    HDU 3367 Pseudoforest
    USACO 2001 OPEN
    HDU 3371 Connect the Cities
    HDU 1301 Jungle Roads
    HDU 1879 继续畅通工程
    HDU 1233 还是畅通工程
    HDU 1162 Eddy's picture
    HDU 5745 La Vie en rose
    HDU 5744 Keep On Movin
  • 原文地址:https://www.cnblogs.com/python-kp/p/14955087.html
Copyright © 2011-2022 走看看