【问题标题】:An error when executing pycrypto执行 pycrypto 时出错
【发布时间】:2015-02-11 21:16:04
【问题描述】:

我使用 odoo,我想安装 paybox 模块:这个:https://bitbucket.org/anybox/anybox_paybox/ 为此:这个模块需要 pycrypto 才能工作

所以,我在linux服务器(ubuntu)中安装了pycrypto

  1. git clone https://github.com/dlitz/pycrypto.git
  2. ./configure
  3. python setup.py build
  4. python setup.py install

我做了这个测试:python setup.py test 结果没有错误,但问题来了:在这个文件中 //paybox_signature.py//

# coding: utf-8
import urllib
import base64
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
from Crypto.Hash import SHA

class Signature():

def verify(self, signature, msg, key):
    """ check if the signature is correct according to the public key path         given
        and the message """
    msg = self.remove_sign(msg)
    key = RSA.importKey(key)
    ha = SHA.SHA1Hash().new(msg)
    verifier = PKCS1_v1_5.new(key)
    signature = urllib.unquote(signature)
    signature = base64.b64decode(signature)
    return verifier.verify(ha, signature)

    def remove_sign(self, msg):
    """ remove signature arg from the given string"""
    pos = msg.find('&Signature')
    if pos == -1:
        return msg
    return msg[:pos] 

当我执行文件的这一行时:

from Crypto.PublicKey import RSA

--> 没问题就ok

当我这样做时

from Crypto.Signature import PKCS1_v1_5

--> Traceback(最近一次调用最后一次): 文件“”,第 1 行,在 ImportError: 没有名为 Signature 的模块

我不知道为什么 所有模块都在那里,为什么python会出现这个错误!我真的不知道 我需要你的帮助谢谢你

【问题讨论】:

    标签: python odoo pycrypto


    【解决方案1】:

    pycrypto 软件包安装可能存在问题。

    试试

    sudo easy_install pycrypto
    

    然后重新启动您的系统。

    您也可以结帐api of pycrypto

    如果你使用 Mac OS 比看更多讨论here

    【讨论】:

    • 我试过这个并且它产生了这个错误: Traceback (last recent call last): File "/usr/local/bin/easy_install", line 5, in from pkg_resources import load_entry_point File " /usr/lib/python2.7/dist-packages/pkg_resources.py”,第 2711 行,在 parse_requirements(requires),Environment() 文件“/usr/lib/python2.7 /dist-packages/pkg_resources.py",第 584 行,在解决提高 DistributionNotFound(req) pkg_resources.DistributionNotFound: setuptools>=0.7
    【解决方案2】:

    这是一个老问题,但对于仍在寻找答案并偶然发现此页面的人来说。你可以从pycrypto dist下载pyCrypto,但我推荐“pip install pyCrypto”,因为它更简单更好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-26
      • 1970-01-01
      相关资源
      最近更新 更多