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

    至此,终于完成安装了。

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

        

  • 相关阅读:
    Django匆匆一眼却解答了多年疑惑
    2020年度总结,似乎没有什么大的长进,似乎也得到了一些收获
    Django搭建示例项目实战与避坑细节
    真香,理解记忆法学习Python基础语法
    如何让文科生5分钟写上Python
    Django官方为什么没有标准项目结构
    用PyCharm打个专业的招呼
    MySQL/MariaDB读写分离配置
    Mysql/Mariadb主从复制
    图解CentOS系统启动流程
  • 原文地址:https://www.cnblogs.com/python-kp/p/14955087.html
Copyright © 2011-2022 走看看